本文整理匯總了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))