当前位置: 首页>>代码示例>>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;未经允许,请勿转载。