本文整理汇总了Python中cqlparser.cqltoexpression.QueryExpression.searchterm方法的典型用法代码示例。如果您正苦于以下问题:Python QueryExpression.searchterm方法的具体用法?Python QueryExpression.searchterm怎么用?Python QueryExpression.searchterm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cqlparser.cqltoexpression.QueryExpression
的用法示例。
在下文中一共展示了QueryExpression.searchterm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testQueryExpression
# 需要导入模块: from cqlparser.cqltoexpression import QueryExpression [as 别名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import searchterm [as 别名]
def testQueryExpression(self):
conversion = Conversion()
kwargs = {'q': QueryExpression.searchterm(term='term')}
dump = conversion.jsonDumpMessage(message='aMessage', **kwargs)
loadedMessage, loadedKwargs = conversion.jsonLoadMessage(dump)
self.assertEquals('aMessage', loadedMessage)
self.assertEquals({'q': QueryExpression.searchterm(term='term')}, loadedKwargs)
示例2: testBooleanNotQueryNested
# 需要导入模块: from cqlparser.cqltoexpression import QueryExpression [as 别名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import searchterm [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))
示例3: testQueryExpressionWithOperands
# 需要导入模块: from cqlparser.cqltoexpression import QueryExpression [as 别名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import searchterm [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)
示例4: testEquals
# 需要导入模块: from cqlparser.cqltoexpression import QueryExpression [as 别名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import searchterm [as 别名]
def testEquals(self):
self.assertEquals(QueryExpression(index='field', relation='=', term='term'), QueryExpression(index='field', relation='=', term='term'))
self.assertEquals(cqlToExpression('field=value AND otherfield=othervalue'), QueryExpression(operator='AND', operands=[QE('field=value'), QE('otherfield=othervalue')]))
self.assertTrue(QueryExpression.searchterm('a') == QueryExpression.searchterm('a'))
self.assertFalse(QueryExpression.searchterm('a') != QueryExpression.searchterm('a'))
self.assertFalse(QueryExpression.searchterm('a') == QueryExpression.searchterm('b'))
self.assertTrue(QueryExpression.searchterm('a') != QueryExpression.searchterm('b'))
示例5: testIntRangeQuery
# 需要导入模块: from cqlparser.cqltoexpression import QueryExpression [as 别名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import searchterm [as 别名]
def testIntRangeQuery(self):
# (field, lowerTerm, upperTerm, includeLower, includeUpper)
q = dict(type="RangeQuery", rangeType="Int", field='intField', lowerTerm=1, upperTerm=None, includeLower=False, includeUpper=True)
self.assertEquals(q, self._convert('intField > 1'))
q = dict(type="RangeQuery", rangeType="Int", field='intField', lowerTerm=1, upperTerm=None, includeLower=True, includeUpper=True)
self.assertEquals(q, self._convert('intField >= 1'))
q = dict(type="RangeQuery", rangeType="Int", field='intField', lowerTerm=None, upperTerm=3, includeLower=True, includeUpper=False)
self.assertEquals(q, self._convert('intField < 3'))
q = dict(type="RangeQuery", rangeType="Int", field='intField', lowerTerm=None, upperTerm=3, includeLower=True, includeUpper=True)
self.assertEquals(q, self._convert('intField <= 3'))
q = dict(type="RangeQuery", rangeType="Int", field='intField', lowerTerm=3, upperTerm=3, includeLower=True, includeUpper=True)
self.assertEquals(q, self._convert('intField = 3'))
self.assertEquals(q, self._convert(QueryExpression.searchterm(index='intField', relation='exact', term=3)))
self.assertEquals(q, self._convert(QueryExpression.searchterm(index='intField', relation='=', term=3)))
示例6: testUnqualifiedTermFieldsWithNestedExpression
# 需要导入模块: from cqlparser.cqltoexpression import QueryExpression [as 别名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import searchterm [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))
示例7: convert
# 需要导入模块: from cqlparser.cqltoexpression import QueryExpression [as 别名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import searchterm [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))
示例8: testTermQuery
# 需要导入模块: from cqlparser.cqltoexpression import QueryExpression [as 别名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import searchterm [as 别名]
def testTermQuery(self):
self.assertConversion({
"type": "TermQuery",
"term": {
"field":"field",
"value": "value",
}
}, QueryExpression.searchterm("field", "=", "value"))
self.assertConversion({"term": {"field": "field", "value": "value"}, "type": "TermQuery"}, QueryExpression.searchterm("field", "=", "value"))
示例9: testPhraseOutput
# 需要导入模块: from cqlparser.cqltoexpression import QueryExpression [as 别名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import searchterm [as 别名]
def testPhraseOutput(self):
self.assertConversion({
"type": "PhraseQuery",
"boost": 1.0,
"terms": [
{"field": "unqualified", "value": "cats"},
{"field": "unqualified", "value": "dogs"}
]
}, QueryExpression.searchterm(term='"cats dogs"'))
示例10: testBooleanOrQuery
# 需要导入模块: from cqlparser.cqltoexpression import QueryExpression [as 别名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import searchterm [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)
示例11: testTermQuery
# 需要导入模块: from cqlparser.cqltoexpression import QueryExpression [as 别名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import searchterm [as 别名]
def testTermQuery(self):
self.assertEquals(
{
"type": "TermQuery",
"term": {
"field":"field",
"value": "value",
}
}, self._convert(QueryExpression.searchterm("field", "=", "value")))
self.assertEquals(
{"term": {"field": "field", "value": "value"}, "type": "TermQuery"}, self._convert(QueryExpression.searchterm("field", "=", "value")))
示例12: testBooleanAndQuery
# 需要导入模块: from cqlparser.cqltoexpression import QueryExpression [as 别名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import searchterm [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))
示例13: testBooleanNotQuery
# 需要导入模块: from cqlparser.cqltoexpression import QueryExpression [as 别名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import searchterm [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)
示例14: convert
# 需要导入模块: from cqlparser.cqltoexpression import QueryExpression [as 别名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import searchterm [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))
示例15: testOtherCoreAndQuery
# 需要导入模块: from cqlparser.cqltoexpression import QueryExpression [as 别名]
# 或者: from cqlparser.cqltoexpression.QueryExpression import searchterm [as 别名]
def testOtherCoreAndQuery(self):
self.assertEquals({
'type': 'JoinAndQuery',
'first': {
"type": "RelationalLuceneQuery", # should this not be 'joined' to own core somehow?
"core": "thisCore",
"collectKeyName": "A", # where does this keyName come from?
"filterKeyName": "A",
"query": {
"type": "TermQuery",
"term": {
"field":"field0",
"value": "value",
}
}
},
'second': {
"type": "RelationalLuceneQuery", # should this not be 'joined' to own core somehow?
"core": "otherCore",
"collectKeyName": "A", # where does this keyName come from?
"filterKeyName": "A",
"query": {
"type": "TermQuery",
"term": {
"field":"field",
"value": "value",
}
}
}
}, self._convert(
QueryExpression(operator='AND', operands=[
QueryExpression.searchterm('field0', '=', 'value'),
QueryExpression.searchterm("otherCore.field", "=", "value")
])
)
)