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


Python QueryParser.toString方法代码示例

本文整理汇总了Python中lucene.QueryParser.toString方法的典型用法代码示例。如果您正苦于以下问题:Python QueryParser.toString方法的具体用法?Python QueryParser.toString怎么用?Python QueryParser.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lucene.QueryParser的用法示例。


在下文中一共展示了QueryParser.toString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testSlop

# 需要导入模块: from lucene import QueryParser [as 别名]
# 或者: from lucene.QueryParser import toString [as 别名]
    def testSlop(self):

        q = QueryParser(Version.LUCENE_CURRENT, "field", self.analyzer).parse('"exact phrase"')
        self.assertEqual('"exact phrase"', q.toString("field"), "zero slop")

        qp = QueryParser(Version.LUCENE_CURRENT, "field", self.analyzer)
        qp.setPhraseSlop(5)
        q = qp.parse('"sloppy phrase"')
        self.assertEqual('"sloppy phrase"~5', q.toString("field"), "sloppy, implicitly")
开发者ID:bpgriner01,项目名称:pylucene,代码行数:11,代码来源:QueryParserTest.py

示例2: testLowercasing

# 需要导入模块: from lucene import QueryParser [as 别名]
# 或者: from lucene.QueryParser import toString [as 别名]
    def testLowercasing(self):

        q = QueryParser(Version.LUCENE_CURRENT, "field", self.analyzer).parse("PrefixQuery*")
        self.assertEqual("prefixquery*", q.toString("field"), "lowercased")

        qp = QueryParser(Version.LUCENE_CURRENT, "field", self.analyzer)
        qp.setLowercaseExpandedTerms(False)
        q = qp.parse("PrefixQuery*")
        self.assertEqual("PrefixQuery*", q.toString("field"), "not lowercased")
开发者ID:bpgriner01,项目名称:pylucene,代码行数:11,代码来源:QueryParserTest.py

示例3: testPhraseQuery

# 需要导入模块: from lucene import QueryParser [as 别名]
# 或者: from lucene.QueryParser import toString [as 别名]
    def testPhraseQuery(self):

        analyzer = StandardAnalyzer(Version.LUCENE_24)
        q = QueryParser(Version.LUCENE_24, "field", analyzer).parse('"This is Some Phrase*"')
        self.assertEqual('"some phrase"', q.toString("field"), "analyzed")

        q = QueryParser(Version.LUCENE_CURRENT, "field", self.analyzer).parse('"term"')
        self.assert_(TermQuery.instance_(q), "reduced to TermQuery")
开发者ID:bpgriner01,项目名称:pylucene,代码行数:10,代码来源:QueryParserTest.py

示例4: main

# 需要导入模块: from lucene import QueryParser [as 别名]
# 或者: from lucene.QueryParser import toString [as 别名]
    def main(cls):

        query = QueryParser(Version.LUCENE_CURRENT, "content",
                            cls.synonymAnalyzer).parse('"fox jumps"')
        print "\"fox jumps\" parses to ", query.toString("content")

        print "From AnalyzerUtils.tokensFromAnalysis: "
        AnalyzerUtils.displayTokens(cls.synonymAnalyzer, "\"fox jumps\"")
        print ''
开发者ID:chihyu14,项目名称:pylucene,代码行数:11,代码来源:SynonymAnalyzerTest.py

示例5: testPhraseQuery

# 需要导入模块: from lucene import QueryParser [as 别名]
# 或者: from lucene.QueryParser import toString [as 别名]
    def testPhraseQuery(self):

        analyzer = StandardAnalyzer(Version.LUCENE_24)
        q = QueryParser(Version.LUCENE_24, "field",
                        analyzer).parse('"This is Some Phrase*"')
        self.assertEqual("\"some phrase\"", q.toString("field"), "analyzed")

        q = QueryParser(Version.LUCENE_CURRENT, "field",
                        self.analyzer).parse('"term"')
        self.assert_("TermQuery" == q.getClassName(), "reduced to TermQuery")
开发者ID:ustramooner,项目名称:python-lucenepp,代码行数:12,代码来源:QueryParserTest.py

示例6: testAnalyzer

# 需要导入模块: from lucene import QueryParser [as 别名]
# 或者: from lucene.QueryParser import toString [as 别名]
    def testAnalyzer(self):

        analyzer = StandardAnalyzer(Version.LUCENE_CURRENT)
        queryString = "category:/philosophy/eastern"

        query = QueryParser(Version.LUCENE_CURRENT,
                            "contents", analyzer).parse(queryString)

        self.assertEqual("category:\"philosophy eastern\"",
                         query.toString("contents"), "path got split, yikes!")

        perFieldAnalyzer = PerFieldAnalyzerWrapper(analyzer)
        perFieldAnalyzer.addAnalyzer("category", WhitespaceAnalyzer())
        query = QueryParser(Version.LUCENE_CURRENT,
                            "contents", perFieldAnalyzer).parse(queryString)

        self.assertEqual("category:/philosophy/eastern",
                         query.toString("contents"),
                         "leave category field alone")
开发者ID:ustramooner,项目名称:python-lucenepp,代码行数:21,代码来源:AnalysisParalysisTest.py

示例7: testBasicQueryParser

# 需要导入模块: from lucene import QueryParser [as 别名]
# 或者: from lucene.QueryParser import toString [as 别名]
    def testBasicQueryParser(self):

        analyzer = SimpleAnalyzer()
        query = QueryParser(Version.LUCENE_CURRENT, "description",
                            analyzer).parse("partnum:Q36 AND SPACE")

        scoreDocs = self.searcher.search(query, 50).scoreDocs
        self.assertEqual("+partnum:q +space", query.toString("description"),
                         "note Q36 -> q")
        self.assertEqual(0, len(scoreDocs), "doc not found :(")
开发者ID:qiugen,项目名称:pylucene-trunk,代码行数:12,代码来源:KeywordAnalyzerTest.py

示例8: testBoost

# 需要导入模块: from lucene import QueryParser [as 别名]
# 或者: from lucene.QueryParser import toString [as 别名]
    def testBoost(self):

        q = QueryParser(Version.LUCENE_CURRENT, "field", self.analyzer).parse("term^2")
        self.assertEqual("term^2.0", q.toString("field"))
开发者ID:bpgriner01,项目名称:pylucene,代码行数:6,代码来源:QueryParserTest.py


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