本文整理汇总了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")
示例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")
示例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")
示例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 ''
示例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")
示例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")
示例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 :(")
示例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"))