当前位置: 首页>>代码示例>>Python>>正文


Python QueryParser.replace_plugin方法代码示例

本文整理汇总了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
开发者ID:wahaproject,项目名称:asmaa,代码行数:16,代码来源:asm_indexer.py

示例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
开发者ID:AlecChou,项目名称:ldoce5viewer,代码行数:34,代码来源:fulltext.py


注:本文中的whoosh.qparser.QueryParser.replace_plugin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。