【发布时间】:2013-09-25 10:57:56
【问题描述】:
我正在使用 python 和 Flask-Whooshalchemy 构建文本搜索,目前我有这样的东西:
Entry.query.whoosh_search('something').all()
通过条目的正文和标题。但是,仅当内容具有该确切字符串时,它才会返回 true。比如
Entry.query.whoosh_search('cat').all()
返回带有“我有一只猫”而不是“家猫”或“猫”的条目。
如何让搜索在字符串中找到字符串?
【问题讨论】:
-
根据here 的回复,您可能想试试
Entry.query.whoosh_search('*cat*').all()(添加*)。根据链接的回复,应该在 Whoosh 中调用默认whoosh.qparser.QueryParser中的whoosh.query.Wildcard类,我相信 WhooshAlchemy 默认使用它。
标签: python search flask whoosh