调用whoosh_search方法查Post.query.whoosh_search('mus').all()
查到的结果:
E:Python27libsite-packagessqlalchemysqlelements.py:4230: SAWarning: Textual SQL expression 'null' should be explicitly declared as text('null') (this warning may be suppressed after 10 occurrences)
{"expr": util.ellipses_string(element)})
[]
我查的字段 searchable = ['title'];
打印结果:
SELECT posts.id AS posts_id, posts.title AS posts_title, posts.body AS posts_body, posts.created AS posts_created, posts.clicks AS posts_clicks, posts.author_id AS posts_author_id
FROM posts
WHERE null
where null 是什么怎么回事啊?
我数据库title里面确实有mus这个词的
还有问题就是下面这个search.db是什么意思,网上用flask_whooshalchemy的资料只有一篇
app.config['WHOOSH_BASE']=os.path.join(basedir, 'data.sqlite')
shell里面调用whoosh_index()函数是报错:
where null
是因为whoosh搜索时结果为空,查看源码可以看出search.db是whoosh建立并保存索引的地方
另外,我来推荐一下我参考flask_whooshalchemy写的搜索扩展,使用上可能更方便一些
https://github.com/honmaple/flask-msearch