本文整理汇总了Python中whoosh.qparser.MultifieldParser.replace_plugin方法的典型用法代码示例。如果您正苦于以下问题:Python MultifieldParser.replace_plugin方法的具体用法?Python MultifieldParser.replace_plugin怎么用?Python MultifieldParser.replace_plugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类whoosh.qparser.MultifieldParser
的用法示例。
在下文中一共展示了MultifieldParser.replace_plugin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: lookup
# 需要导入模块: from whoosh.qparser import MultifieldParser [as 别名]
# 或者: from whoosh.qparser.MultifieldParser import replace_plugin [as 别名]
def lookup(self, term, fuzzy=False, limit=None):
term = term.strip()
term = term.lower()
if limit:
limit = limit
else:
limit = self.RESULTS_LIMIT
fields = (
'indice',
'indice_game',
'name',
'name_jp',
'game',
'version',
'classification',
'element',
'code',
'size',
'damage_min',
'damage_max',
'recovery',
'rarity'
)
if fuzzy:
parser = MultifieldParser(
fields,
schema=self.index.schema,
termclass=FuzzyTerm
)
else:
parser = MultifieldParser(fields, schema=self.index.schema)
operators = OperatorsPlugin(
And="&",
Or="\\|",
AndNot="&!",
AndMaybe="&~",
Not="\\-"
)
parser.replace_plugin(operators)
query = parser.parse(term)
results = []
try:
searcher = self.index.searcher()
results = searcher.search(query, limit=limit)
if not results and not fuzzy:
# Try a Fuzzy Search.
return self.lookup(term, fuzzy=True, limit=self.FUZZY_LIMIT)
except IndexError:
pass
return results