如何手动导入flask

如何手动导入flask

本文介绍了如何手动导入flask-whooshalchemy索引数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在sqlite上使用了flask-whooshalchemy,并且手动导入了大量的数据,现在谁可以搜索它们。我想这是因为whoosh没有索引任何数据,对吧?我怎么能手动添加这些数据whoosh索引?

解决方案

看看



我已经只是写这个来解决同样的问题 - 大量数据导入后重建搜索索引。

它不会为任何其他人(我的lib import包含了我所有的第三方库,并且你需要在if 名称 == < main 块中指定你的Flask-SQLAlchemy模型),但是它应该如文件注释中所述,您应该考虑删除您的search.db文件夹(WHOOSH_BASE),因为此脚本不会删除已删除的数据,只重新索引当前数据集。



我发现使用SQLAlchemy核心导入所有数据,然后运行这个脚本比impo快得多通过SQLAlchemy ORM通过动态的Whoosh索引更新来处理我的数据(44s vs 48m用于我的数据集)。

I'm using flask-whooshalchemy on sqlite, and mannually imported a lot of data, now whoosh can search none of it. I think it's because whoosh haven't indexed any of the data, right? How could I add whoosh index on those data manually?

解决方案

Have a look at https://gist.github.com/davb5/21fbffd7a7990f5e066c

I've just written this to solve the same issue - rebuild search indices after a bulk data import.

It won't work out of the box for anyone else (my "lib" import contains all of my third party libraries, and you'll need to specify your Flask-SQLAlchemy models in the if name=="main" block), but it should be enough to get you started.

As stated in the file comments, you should consider deleting your search.db folder (WHOOSH_BASE) as this script doesn't remove deleted data, only re-indexes the current data set.

I've found it to be much quicker importing all of my data using SQLAlchemy core then running this script compared to importing my data via SQLAlchemy ORM with on-the-fly Whoosh index updates (44s vs 48m for my data set).

这篇关于如何手动导入flask-whooshalchemy索引数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 14:32