本文整理汇总了Python中meresco.lucene.composedquery.ComposedQuery.addFilterQuery方法的典型用法代码示例。如果您正苦于以下问题:Python ComposedQuery.addFilterQuery方法的具体用法?Python ComposedQuery.addFilterQuery怎么用?Python ComposedQuery.addFilterQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meresco.lucene.composedquery.ComposedQuery
的用法示例。
在下文中一共展示了ComposedQuery.addFilterQuery方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testAsDictFromDict
# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import addFilterQuery [as 别名]
def testAsDictFromDict(self):
cq = ComposedQuery('coreA')
cq.setCoreQuery(core='coreA', query='Q0')
cq.addFilterQuery(core='coreA', query='Q1')
cq.addFilterQuery(core='coreA', query='Q2')
cq.addFacet(core='coreA', facet='F0')
cq.addFacet(core='coreA', facet='F1')
cq.setCoreQuery(core='coreB', query='Q3')
cq.addMatch(dict(core='coreA', uniqueKey='keyA'), dict(core='coreB', key='keyB'))
cq.addUnite(dict(core='coreA', query='AQuery'), dict(core='coreB', query='anotherQuery'))
cq.start = 0
cq.sortKeys = [dict(sortBy='field', sortDescending=True)]
cq.clustering = True
cq.clusteringConfig = {'clusteringEps': 0.2}
d = cq.asDict()
cq2 = ComposedQuery.fromDict(d)
self.assertEquals('coreA', cq2.resultsFrom)
self.assertEquals(0, cq2.start)
self.assertEquals(None, cq2.stop)
self.assertEquals(['Q0', 'Q1', 'Q2'], cq2.queriesFor('coreA'))
self.assertEquals(['F0', 'F1'], cq2.facetsFor('coreA'))
self.assertEquals('keyA', cq2.keyName('coreA', 'coreB'))
self.assertEquals('keyB', cq2.keyName('coreB', 'coreA'))
self.assertEqual(1, len(cq2.unites))
queries = list(cq2.unites[0].queries())
self.assertEquals(({'core': 'coreA', 'keyName': 'keyA', 'query': 'AQuery'}, 'keyA'), queries[0])
self.assertEquals(({'core': 'coreB', 'keyName': 'keyB', 'query': 'anotherQuery'}, 'keyA'), queries[1])
self.assertEquals({'clusteringEps': 0.2}, cq2.clusteringConfig)
示例2: testInfoOnQuery
# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import addFilterQuery [as 别名]
def testInfoOnQuery(self):
self.response = JsonDict({
"total": 887,
"queryTime": 6,
"hits": [{"id": "record:1", "score": 0.1234}]
}).dumps()
q = ComposedQuery('coreA')
q.addFilterQuery('coreB', query='N=true')
q.addMatch(dict(core='coreA', uniqueKey='A'), dict(core='coreB', key='B'))
result = retval(self._multiLucene.executeComposedQuery(q))
self.assertEquals({
'query': {
'cores': ['coreB', 'coreA'],
'drilldownQueries': {},
'facets': {},
'filterQueries': {'coreB': ['N=true']},
'matches': {'coreA->coreB': [{'core': 'coreA', 'uniqueKey': 'A'}, {'core': 'coreB', 'key': 'B'}]},
'otherCoreFacetFilters': {},
'queries': {},
'rankQueries': {},
'resultsFrom': 'coreA',
'sortKeys': [],
'unites': []
},
'type': 'ComposedQuery'
}, result.info)
示例3: testJoinQueryWithFilters
# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import addFilterQuery [as 别名]
def testJoinQueryWithFilters(self):
q = ComposedQuery('coreA')
q.addFilterQuery('coreB', query=luceneQueryFromCql('N=true'))
q.addMatch(dict(core='coreA', uniqueKey=KEY_PREFIX+'A'), dict(core='coreB', key=KEY_PREFIX+'B'))
result = returnValueFromGenerator(self.dna.any.executeComposedQuery(q))
self.assertEquals(4, result.total)
self.assertEquals(set(['A-M', 'A-MU', 'A-MQ', 'A-MQU']), self.hitIds(result.hits))
示例4: testUniteResultFromTwoIndexes_filterQueries
# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import addFilterQuery [as 别名]
def testUniteResultFromTwoIndexes_filterQueries(self):
q = ComposedQuery('coreA')
q.addFilterQuery(core='coreA', query=luceneQueryFromCql('Q=true'))
q.addMatch(dict(core='coreA', uniqueKey=KEY_PREFIX+'A'), dict(core='coreB', key=KEY_PREFIX+'B'))
q.addUnite(dict(core='coreA', query=luceneQueryFromCql('U=true')), dict(core='coreB', query=luceneQueryFromCql('N=true')))
result = returnValueFromGenerator(self.dna.any.executeComposedQuery(q))
self.assertEquals(3, result.total)
self.assertEquals(set(['A-QU', 'A-MQ', 'A-MQU']), self.hitIds(result.hits))
示例5: testAddFilterQueryAfterConversion
# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import addFilterQuery [as 别名]
def testAddFilterQueryAfterConversion(self):
cq = ComposedQuery('coreA')
cq.setCoreQuery('coreA', query='A')
cq.convertWith(coreA=lambda q: "converted_" + q)
self.assertEquals('converted_A', cq.queryFor('coreA'))
# Assert the following does not raise KeyError
cq.addFilterQuery('coreA', 'field=value')
cq.addFacet('coreA', 'F0')
cq.addDrilldownQuery('coreA', 'drilldownQuery')
cq.addOtherCoreFacetFilter('coreA', 'q')
示例6: testJoinFacetWithFilter
# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import addFilterQuery [as 别名]
def testJoinFacetWithFilter(self):
q = ComposedQuery('coreA', query=luceneQueryFromCql('M=true'))
q.addFilterQuery('coreA', query=luceneQueryFromCql('Q=true'))
q.addFacet('coreB', dict(fieldname='cat_O', maxTerms=10))
q.addMatch(dict(core='coreA', uniqueKey=KEY_PREFIX + 'A'), dict(core='coreB', key=KEY_PREFIX + 'B'))
result = returnValueFromGenerator(self.dna.any.executeComposedQuery(query=q))
self.assertEquals(2, result.total)
self.assertEquals([{
'terms': [
{'count': 3, 'term': u'false'},
{'count': 1, 'term': u'true'},
],
'path': [],
'fieldname': u'cat_O'
}], result.drilldownData)
示例7: testCachingKeyCollectorsIntersectsWithACopyOfTheKeys
# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import addFilterQuery [as 别名]
def testCachingKeyCollectorsIntersectsWithACopyOfTheKeys(self):
q = ComposedQuery('coreA')
q.setCoreQuery(core='coreA', query=MatchAllDocsQuery())
q.setCoreQuery(core='coreB', query=luceneQueryFromCql("O=true"))
q.addFilterQuery(core='coreB', query=luceneQueryFromCql("N=true"))
q.addMatch(dict(core='coreA', uniqueKey=KEY_PREFIX+'A'), dict(core='coreB', key=KEY_PREFIX+'B'))
result = returnValueFromGenerator(self.dna.any.executeComposedQuery(q))
self.assertEquals(2, len(result.hits))
q = ComposedQuery('coreA')
q.setCoreQuery(core='coreA', query=MatchAllDocsQuery())
q.setCoreQuery(core='coreB', query=MatchAllDocsQuery())
q.addFilterQuery(core='coreB', query=luceneQueryFromCql("N=true"))
q.addMatch(dict(core='coreA', uniqueKey=KEY_PREFIX+'A'), dict(core='coreB', key=KEY_PREFIX+'B'))
result = returnValueFromGenerator(self.dna.any.executeComposedQuery(q))
self.assertEquals(4, len(result.hits))
示例8: testConvertAllQueries
# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import addFilterQuery [as 别名]
def testConvertAllQueries(self):
cq = ComposedQuery('coreA')
cq.setCoreQuery(core='coreA', query='Q0')
cq.addFilterQuery('coreA', 'Q1')
cq.addFilterQuery('coreA', 'Q2')
cq.setCoreQuery(core='coreB', query='Q3')
cq.addFilterQuery('coreB', 'Q4')
cq.addMatch(dict(core='coreA', uniqueKey='keyA'), dict(core='coreB', key='keyB'))
cq.addUnite(dict(core='coreA', query='Q5'), dict(core='coreB', query='Q6'))
convertCoreA = lambda query: "Converted_A_{0}".format(query)
convertCoreB = lambda query: "Converted_B_{0}".format(query)
cq.convertWith(coreA=convertCoreA, coreB=convertCoreB)
self.assertEquals("Converted_A_Q0", cq.queryFor('coreA'))
self.assertEquals(["Converted_A_Q1", "Converted_A_Q2"], cq.filterQueriesFor('coreA'))
self.assertEquals("Converted_B_Q3", cq.queryFor('coreB'))
self.assertEquals(["Converted_B_Q4"], cq.filterQueriesFor('coreB'))
self.assertEquals([('coreA', 'Converted_A_Q5'), ('coreB', 'Converted_B_Q6')], cq.unites)
示例9: testFilterQueries
# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import addFilterQuery [as 别名]
def testFilterQueries(self):
cq = ComposedQuery('coreA')
cq.setCoreQuery(core='coreA', query='Q0')
cq.addFilterQuery(core='coreA', query='Q1')
cq.addFilterQuery(core='coreA', query='Q2')
cq.addFacet(core='coreA', facet='F0')
cq.addFacet(core='coreA', facet='F1')
cq.setCoreQuery(core='coreB', query='Q3')
cq.addMatch(dict(core='coreA', uniqueKey='keyA'), dict(core='coreB', key='keyB'))
cq.addUnite(dict(core='coreA', query='AQuery'), dict(core='coreB', query='anotherQuery'))
self.assertEquals(None, cq.stop)
self.assertEquals(None, cq.start)
self.assertEquals([], cq.sortKeys)
cq.stop = 10
cq.start = 0
cq.sortKeys = [dict(sortBy='field', sortDescending=True)]
self.assertEquals('Q0', cq.queryFor('coreA'))
self.assertEquals(['Q1', 'Q2'], cq.filterQueriesFor('coreA'))
self.assertEquals(['F0', 'F1'], cq.facetsFor('coreA'))
self.assertEquals(10, cq.stop)
self.assertEquals(0, cq.start)
self.assertEquals([dict(sortBy='field', sortDescending=True)], cq.sortKeys)
示例10: testAsDictFromDict
# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import addFilterQuery [as 别名]
def testAsDictFromDict(self):
cq = ComposedQuery('coreA')
cq.setCoreQuery(core='coreA', query='Q0')
cq.addFilterQuery(core='coreA', query='Q1')
cq.addFilterQuery(core='coreA', query='Q2')
cq.addFacet(core='coreA', facet='F0')
cq.addFacet(core='coreA', facet='F1')
cq.setCoreQuery(core='coreB', query='Q3')
cq.addMatch(dict(core='coreA', uniqueKey='keyA'), dict(core='coreB', key='keyB'))
cq.addUnite(dict(core='coreA', query='AQuery'), dict(core='coreB', query='anotherQuery'))
cq.start = 0
cq.sortKeys = [dict(sortBy='field', sortDescending=True)]
d = cq.asDict()
cq2 = ComposedQuery.fromDict(d)
self.assertEquals('coreA', cq2.resultsFrom)
self.assertEquals(0, cq2.start)
self.assertEquals(None, cq2.stop)
self.assertEquals(['Q0', 'Q1', 'Q2'], cq2.queriesFor('coreA'))
self.assertEquals(['F0', 'F1'], cq2.facetsFor('coreA'))
self.assertEquals('keyA', cq2.keyName('coreA'))
self.assertEquals('keyB', cq2.keyName('coreB'))
示例11: testRepr
# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import addFilterQuery [as 别名]
def testRepr(self):
class AQuery(object):
def __repr__(self):
return 'NOT USED'
def __str__(self):
return 'AQuery'
cq = ComposedQuery('coreA')
cq.setCoreQuery(core='coreA', query='Q0')
cq.addFilterQuery(core='coreA', query='Q1')
cq.addFilterQuery(core='coreA', query='Q2')
cq.relationalFilter = '{"type": "MadeUpJoinQuery"}'
cq.addFacet(core='coreA', facet='F0')
cq.addFacet(core='coreA', facet='F1')
cq.setCoreQuery(core='coreB', query='Q3')
cq.addMatch(dict(core='coreA', uniqueKey='keyA'), dict(core='coreB', key='keyB'))
cq.addUnite(dict(core='coreA', query=AQuery()), dict(core='coreB', query='anotherQuery'))
cq.start = 0
cq.sortKeys = [dict(sortBy='field', sortDescending=True)]
cq.storedFields = ['stored_field']
self.assertEquals({
'type': 'ComposedQuery',
'query': {
"cores": ["coreB", "coreA"],
"drilldownQueries": {},
"facets": {"coreA": ["F0", "F1"]},
"filterQueries": {"coreA": ["Q1", "Q2"]},
"matches": {"coreA->coreB": [{"core": "coreA", "uniqueKey": "keyA"}, {"core": "coreB", "key": "keyB"}]},
"otherCoreFacetFilters": {},
"queries": {"coreA": "Q0", "coreB": "Q3"},
"rankQueries": {},
'relationalFilter': '{"type": "MadeUpJoinQuery"}',
"resultsFrom": "coreA",
"sortKeys": [{"sortBy": "field", "sortDescending": True}],
"start": 0,
"storedFields": ['stored_field'],
"unites": [{"A": ["coreA", "AQuery"], "B": ["coreB", "anotherQuery"]}]
}
}, cq.infoDict())
示例12: testConvertAllQueriesWithUnqualifiedTermFields
# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import addFilterQuery [as 别名]
def testConvertAllQueriesWithUnqualifiedTermFields(self):
cq = ComposedQuery('coreA')
cq.setCoreQuery(core='coreA', query='Q0')
cq.addFilterQuery('coreA', 'Q1')
cq.addFilterQuery('coreA', 'Q2')
cq.setCoreQuery(core='coreB', query='Q3')
cq.addFilterQuery('coreB', 'Q4')
cq.addMatch(dict(core='coreA', uniqueKey='keyA'), dict(core='coreB', key='keyB'))
cq.addUnite(dict(core='coreA', query='Q5'), dict(core='coreB', query='Q6'))
cq.unqualifiedTermFields = [('field0', 2.0), ('field1', 3.0)]
convertCoreA = lambda query, unqualifiedTermFields=None, **kwargs: "Converted_A_{0}_{1}".format(query, not unqualifiedTermFields is None)
convertCoreB = lambda query, **kwargs: "Converted_B_{0}".format(query)
cq.convertWith(coreA=convertCoreA, coreB=convertCoreB)
self.assertEquals("Converted_A_Q0_True", cq.queryFor('coreA'))
self.assertEquals(["Converted_A_Q1_True", "Converted_A_Q2_True"], cq.filterQueriesFor('coreA'))
self.assertEquals("Converted_B_Q3", cq.queryFor('coreB'))
self.assertEquals(["Converted_B_Q4"], cq.filterQueriesFor('coreB'))
self.assertEqual(1, len(cq.unites))
uniteQueries = list(cq.unites[0].queries())
self.assertEquals('Converted_A_Q5_True', uniteQueries[0][0]['query'])
self.assertEquals('Converted_B_Q6', uniteQueries[1][0]['query'])
示例13: testAddFilterQueriesIncremental
# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import addFilterQuery [as 别名]
def testAddFilterQueriesIncremental(self):
cq = ComposedQuery('coreA')
cq.addFilterQuery(core='coreA', query='Q1')
cq.addFilterQuery(core='coreA', query='Q2')
self.assertEquals(['Q1', 'Q2'], cq.filterQueriesFor('coreA'))