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


Python QueryExpression.nested方法代碼示例

本文整理匯總了Python中cqlparser.cqltoexpression.QueryExpression.nested方法的典型用法代碼示例。如果您正苦於以下問題:Python QueryExpression.nested方法的具體用法?Python QueryExpression.nested怎麽用?Python QueryExpression.nested使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cqlparser.cqltoexpression.QueryExpression的用法示例。


在下文中一共展示了QueryExpression.nested方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testBooleanNotQueryNested

# 需要導入模塊: from cqlparser.cqltoexpression import QueryExpression [as 別名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import nested [as 別名]
 def testBooleanNotQueryNested(self):
     expr = QueryExpression.nested(operator='AND')
     nestedNotExpr = QueryExpression.nested(operator='AND')
     nestedNotExpr.must_not = True
     nestedNotExpr.operands = [
         QueryExpression.searchterm("field2", "=", "value2"),
         QueryExpression.searchterm("field3", "=", "value3")
     ]
     expr.operands = [QueryExpression.searchterm("field1", "=", "value1"), nestedNotExpr]
     self.assertEquals(
         {
             "type": "BooleanQuery",
             "clauses": [
                 {
                     "type": "TermQuery",
                     "term": {"field": "field1", "value": "value1"},
                     "occur": "MUST"
                 }, {
                     "type": "BooleanQuery",
                     "occur": "MUST_NOT",
                     "clauses": [
                         {
                             "type": "TermQuery",
                             "term": {"field": "field2", "value": "value2"},
                             "occur": "MUST"
                         },
                         {
                             "type": "TermQuery",
                             "term": {"field": "field3", "value": "value3"},
                             "occur": "MUST"
                         }
                     ]
                 }
             ]
         }, self._convert(expr))
開發者ID:seecr,項目名稱:meresco-lucene,代碼行數:37,代碼來源:queryexpressiontolucenequerydicttest.py

示例2: convert

# 需要導入模塊: from cqlparser.cqltoexpression import QueryExpression [as 別名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import nested [as 別名]
 def convert(self, expression):
     if expression.must_not:
         r = QueryExpression.nested('AND')
         r.operands.append(QueryExpression.searchterm(term='*'))
         r.operands.append(expression)
         expression = r
     return JsonDict(self._expression(expression))
開發者ID:FashtimeDotCom,項目名稱:meresco-lucene,代碼行數:9,代碼來源:queryexpressiontolucenequerydict.py

示例3: testQueryExpressionWithOperands

# 需要導入模塊: from cqlparser.cqltoexpression import QueryExpression [as 別名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import nested [as 別名]
 def testQueryExpressionWithOperands(self):
     conversion = Conversion()
     qe = QueryExpression.nested(operator='AND')
     qe.operands = [QueryExpression.searchterm(term='term'), QueryExpression.searchterm(term='term1')]
     kwargs = {'q': qe}
     dump = conversion.jsonDumpMessage(message='aMessage', **kwargs)
     loadedMessage, loadedKwargs = conversion.jsonLoadMessage(dump)
     self.assertEquals('aMessage', loadedMessage)
     self.assertEquals({'q': qe}, loadedKwargs)
開發者ID:seecr,項目名稱:meresco-lucene,代碼行數:11,代碼來源:conversiontest.py

示例4: convert

# 需要導入模塊: from cqlparser.cqltoexpression import QueryExpression [as 別名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import nested [as 別名]
 def convert(self, expression, unqualifiedTermFields=None, composedQuery=None):
     if expression.must_not:
         r = QueryExpression.nested('AND')
         r.operands.append(QueryExpression.searchterm(term='*'))
         r.operands.append(expression)
         expression = r
     return JsonDict(_Converter(
         analyzer=self._analyzer,
         fieldRegistry=self._fieldRegistry,
         ignoreStemmingForWords=self._ignoreStemmingForWords,
         unqualifiedTermFields=unqualifiedTermFields or self._unqualifiedTermFields,
         composedQuery=composedQuery).convert(expression))
開發者ID:seecr,項目名稱:meresco-lucene,代碼行數:14,代碼來源:queryexpressiontolucenequerydict.py

示例5: testUnqualifiedTermFieldsWithNestedExpression

# 需要導入模塊: from cqlparser.cqltoexpression import QueryExpression [as 別名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import nested [as 別名]
 def testUnqualifiedTermFieldsWithNestedExpression(self):
     self.unqualifiedFields = [('aField', 1.0)]
     expr = QueryExpression.nested(operator='AND')
     expr.operands = [
         QueryExpression.searchterm(term="value1"),
         QueryExpression.searchterm(term="value2")
     ]
     self.assertEquals({
             'type': 'BooleanQuery',
             'clauses': [
                 {'type': 'TermQuery', 'occur': 'MUST', 'term': {'field': 'aField', 'value': u'value1'}, 'boost': 1.0},
                 {'type': 'TermQuery', 'occur': 'MUST', 'term': {'field': 'aField', 'value': u'value2'}, 'boost': 1.0}
             ],
         },
         self._convert(expr))
開發者ID:seecr,項目名稱:meresco-lucene,代碼行數:17,代碼來源:queryexpressiontolucenequerydicttest.py

示例6: testBooleanOrQuery

# 需要導入模塊: from cqlparser.cqltoexpression import QueryExpression [as 別名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import nested [as 別名]
 def testBooleanOrQuery(self):
     expr = QueryExpression.nested(operator='OR')
     expr.operands=[
             QueryExpression.searchterm("field1", "=", "value1"),
             QueryExpression.searchterm("field2", "=", "value2")
         ]
     self.assertConversion({
             "type": "BooleanQuery",
             "clauses": [
                 {
                     "type": "TermQuery",
                     "term": {"field": "field1", "value": "value1"},
                     "occur": "SHOULD"
                 }, {
                     "type": "TermQuery",
                     "term": {"field": "field2", "value": "value2"},
                     "occur": "SHOULD"
                 }
             ]
         }, expr)
開發者ID:FashtimeDotCom,項目名稱:meresco-lucene,代碼行數:22,代碼來源:queryexpressiontolucenequerydicttest.py

示例7: testBooleanAndQuery

# 需要導入模塊: from cqlparser.cqltoexpression import QueryExpression [as 別名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import nested [as 別名]
 def testBooleanAndQuery(self):
     expr = QueryExpression.nested(operator='AND')
     expr.operands = [
         QueryExpression.searchterm("field1", "=", "value1"),
         QueryExpression.searchterm("field2", "=", "value2")
     ]
     self.assertEquals(
         {
             "type": "BooleanQuery",
             "clauses": [
                 {
                     "type": "TermQuery",
                     "term": {"field": "field1", "value": "value1"},
                     "occur": "MUST"
                 }, {
                     "type": "TermQuery",
                     "term": {"field": "field2", "value": "value2"},
                     "occur": "MUST"
                 }
             ]
         }, self._convert(expr))
開發者ID:seecr,項目名稱:meresco-lucene,代碼行數:23,代碼來源:queryexpressiontolucenequerydicttest.py

示例8: testBooleanNotQuery

# 需要導入模塊: from cqlparser.cqltoexpression import QueryExpression [as 別名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import nested [as 別名]
 def testBooleanNotQuery(self):
     expr = QueryExpression.nested(operator='AND')
     expr.operands=[
             QueryExpression.searchterm("field1", "=", "value1"),
             QueryExpression.searchterm("field2", "=", "value2")
         ]
     expr.operands[1].must_not = True
     self.assertConversion({
             "type": "BooleanQuery",
             "clauses": [
                 {
                     "type": "TermQuery",
                     "term": {"field": "field1", "value": "value1"},
                     "occur": "MUST"
                 }, {
                     "type": "TermQuery",
                     "term": {"field": "field2", "value": "value2"},
                     "occur": "MUST_NOT"
                 }
             ]
         }, expr)
開發者ID:FashtimeDotCom,項目名稱:meresco-lucene,代碼行數:23,代碼來源:queryexpressiontolucenequerydicttest.py

示例9: convert

# 需要導入模塊: from cqlparser.cqltoexpression import QueryExpression [as 別名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import nested [as 別名]
 def convert(self, expression, core):
     filterQueries = {}
     if expression.operator is None or expression.operator == 'OR':
         e = QueryExpression.nested('AND')
         e.operands.append(expression)
         expression = e
     if expression.operator == 'AND':
         oldOperands = expression.operands
         expression.operands = []
         for operand in oldOperands:
             operandCores = list(self.coresInExpression(expression=operand, core=core))
             if len(operandCores) == 1 and operandCores[0] != core:
                 removeCoreFromFieldname(operandCores[0], operand)
                 filterQueries.setdefault(operandCores[0], []).append(operand)
             else:
                 expression.operands.append(operand)
         if len(expression.operands) == 1:
             expression = expression.operands[0]
         elif len(expression.operands) == 0:
             expression = None
     if expression and self.coresInExpression(expression=expression, core=core) != set([core]):
         raise TooComplexQueryExpression('Multiple core query detected, but unable to convert to a correct composed query')
     return expression, filterQueries
開發者ID:FashtimeDotCom,項目名稱:meresco-lucene,代碼行數:25,代碼來源:extractfilterqueries.py


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