Table of Contents
flask 貌似很少全文搜索的插件,有一个 https://github.com/gyllstromk/Flask-WhooshAlchemy , 但试了几次都用不了,所以参考 Flask-WhooshAlchemy 自己写了一个
Quickstart
插件基于 whoosh,纯 python 编写,使用上很简单
from flask_msearch import Search [...] search = Search() search.init_app(app) # models.py class Post(db.Model): __tablename__ = 'post' __searchable__ = ['title', 'content'] # views.py @app.route("/search") def w_search(): keyword = request.args.get('keyword') results = search.whoosh_search(Post,query …