本文整理汇总了Python中whoosh.qparser.QueryParser.replace_plugin方法的典型用法代码示例。如果您正苦于以下问题:Python QueryParser.replace_plugin方法的具体用法?Python QueryParser.replace_plugin怎么用?Python QueryParser.replace_plugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类whoosh.qparser.QueryParser
的用法示例。
在下文中一共展示了QueryParser.replace_plugin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search_in_index
# 需要导入模块: from whoosh.qparser import QueryParser [as 别名]
# 或者: from whoosh.qparser.QueryParser import replace_plugin [as 别名]
def search_in_index(self, text, dict_perf, dict_field, limit):
if dict_field == 'nass':
field = 'content'
else:
field = 'title'
new_index = join(asm_path.INDEX_DIR_rw, 'my_index')
ix = index.open_dir(new_index)
qp = QueryParser(field, schema=ix.schema)
op = OperatorsPlugin(And = r"&", Or = r"\|", AndNot = r"&!", AndMaybe = r"&~", Not = r'!')
qp.replace_plugin(op)
q = qp.parse(text)
with ix.searcher() as s:
r = s.search(q, limit=limit)
return r
示例2: __init__
# 需要导入模块: from whoosh.qparser import QueryParser [as 别名]
# 或者: from whoosh.qparser.QueryParser import replace_plugin [as 别名]
def __init__(self, index_dir, var_path):
self._index = None
try:
self._index = wh_index.open_dir(index_dir)
except wh_index.IndexError:
raise IndexError
self._var_reader = self._make_var_reader(var_path)
op = OperatorsPlugin(
And=r"\bAND\b|&", Or=None, # r"\bOR\b|\|",
Not=r"\bNOT\b|\s+-", AndMaybe=None, Require=None)
parser = QueryParser('content', _schema,
termclass=my_variations(self._var_reader))
parser.remove_plugin_class(RangePlugin)
parser.remove_plugin_class(BoostPlugin)
parser.remove_plugin_class(WildcardPlugin)
parser.replace_plugin(op)
self._parser = parser
parser_wild = QueryParser('content', _schema,
termclass=my_variations(self._var_reader))
parser_wild.remove_plugin_class(RangePlugin)
parser_wild.remove_plugin_class(BoostPlugin)
parser_wild.replace_plugin(op)
self._parser_wild = parser_wild
op_filter = OperatorsPlugin(And=r"\bAND\b", Or=r"\bOR\b",
Not=None, AndMaybe=None, Require=None)
asf_parser = QueryParser('asfilter', _schema)
asf_parser.replace_plugin(op_filter)
self._asf_parser = asf_parser