本文整理汇总了Python中lucene.QueryParser.setLocale方法的典型用法代码示例。如果您正苦于以下问题:Python QueryParser.setLocale方法的具体用法?Python QueryParser.setLocale怎么用?Python QueryParser.setLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lucene.QueryParser
的用法示例。
在下文中一共展示了QueryParser.setLocale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testDateRangeQuery
# 需要导入模块: from lucene import QueryParser [as 别名]
# 或者: from lucene.QueryParser import setLocale [as 别名]
def testDateRangeQuery(self):
# locale diff between jre and gcj 1/1/04 -> 01/01/04
# expression = "modified:[1/1/04 TO 12/31/04]"
expression = "modified:[01/01/04 TO 12/31/04]"
parser = QueryParser(Version.LUCENE_CURRENT, "subject", self.analyzer)
parser.setLocale(Locale.US)
query = parser.parse(expression)
print expression, "parsed to", query
topDocs = self.searcher.search(query, 50)
self.assert_(topDocs.totalHits > 0)
示例2: testDateRangeQuery
# 需要导入模块: from lucene import QueryParser [as 别名]
# 或者: from lucene.QueryParser import setLocale [as 别名]
def testDateRangeQuery(self):
# locale diff between jre and gcj 1/1/04 -> 01/01/04
# expression = "modified:[1/1/04 TO 12/31/04]"
#expression = "modified:[01/01/04 TO 31/12/04]"
#parser = QueryParser(Version.LUCENE_CURRENT, "subject", self.analyzer)
#parser.setLocale(Locale("en_US.utf8"))
#query = parser.parse(expression)
#print expression, "parsed to", query
#TODO: locale problem currently...
expression = "modified:[04/01/01 TO 04/12/31]"
parser = QueryParser(Version.LUCENE_CURRENT, "subject", self.analyzer)
parser.setLocale(Locale("en_US.utf8"))
query = parser.parse(expression)
print expression, "parsed to", query
topDocs = self.searcher.search(query, 50)
#self.assert_(topDocs.totalHits > 0) no docs?
self.assert_(str(expression) != str(query))