首页 > 解决方案 > Python Whoosh 多字段解析器日期和字符串

问题描述

我正在构建一个搜索引擎,并希望同时搜索字符串和日期。在我的索引date中是我的日期字段,name是我的字符串字段:

ix = index.open_dir(dirname)
schema = ix.schema

mp = qparser.MultifieldParser(['date', 'name'], schema, group = og, termclass=FuzzyTerm)

# Add the DateParserPlugin to the parser
mp.add_plugin(DateParserPlugin(free=True))

Whoosh 文档中的日期搜索示例包括日期字段作为日期搜索的前缀,例如:

q = qp.parse(u"date:2005062401")      

在多字段查询中,如何结合字符串解析日期?字符串字段是否像下面的示例那样与日期分开?

q = qp.parse(u"date:2005062401, name:tom")      

我在文档中找不到这个问题的答案,因此我在这里问。

参考资料:https ://whoosh.readthedocs.io/en/latest/dates.html

标签: pythonsearch-enginewhoosh

解决方案


推荐阅读