當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。