當前位置: 首頁>>代碼示例>>Python>>正文


Python QueryParser.setLocale方法代碼示例

本文整理匯總了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)
開發者ID:bpgriner01,項目名稱:pylucene,代碼行數:15,代碼來源:QueryParserTest.py

示例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))
開發者ID:ustramooner,項目名稱:python-lucenepp,代碼行數:23,代碼來源:QueryParserTest.py


注:本文中的lucene.QueryParser.setLocale方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。