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


Python MultifieldParser.replace_plugin方法代码示例

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


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