本文整理汇总了Python中meresco.lucene.composedquery.ComposedQuery类的典型用法代码示例。如果您正苦于以下问题:Python ComposedQuery类的具体用法?Python ComposedQuery怎么用?Python ComposedQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ComposedQuery类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: XXX_NOT_YET_IMPLEMENTED_testRankQueryInSingleCoreQuery
def XXX_NOT_YET_IMPLEMENTED_testRankQueryInSingleCoreQuery(self):
q = ComposedQuery('coreA', query=MatchAllDocsQuery())
q.addMatch(dict(core='coreA', uniqueKey=KEY_PREFIX+'A'), dict(core='coreB', key=KEY_PREFIX+'B'))
q.setRankQuery(core='coreA', query=luceneQueryFromCql('Q=true'))
result = returnValueFromGenerator(self.dna.any.executeComposedQuery(q))
self.assertEquals(8, result.total)
self.assertEquals([u'A-Q', u'A-QU', u'A-MQ', u'A-MQU', u'A', u'A-U', u'A-M', u'A-MU'], [hit.id for hit in result.hits])
开发者ID:jerryba,项目名称:meresco-lucene,代码行数:7,代码来源:multilucenetest.py
示例2: testInfoOnQuery
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)
开发者ID:seecr,项目名称:meresco-lucene,代码行数:27,代码来源:multilucenetest.py
示例3: testComposedQuery
def testComposedQuery(self):
self.response = JsonDict({
"total": 887,
"queryTime": 6,
"hits": [{"id": "record:1", "score": 0.1234}]
}).dumps()
cq = ComposedQuery('coreA')
q = QueryExpressionToLuceneQueryDict([], LuceneSettings()).convert(cqlToExpression("field=value"))
cq.setCoreQuery("coreA", q)
consume(self._multiLucene.executeComposedQuery(cq))
self.assertEqual(1, len(self.post))
self.assertEqual("/query/", self.post[0]['path'])
self.assertEqual({
"_sortKeys": [],
"resultsFrom": "coreA",
"_matches": {},
"_facets": {},
"_otherCoreFacetFilters": {},
"_rankQueries": {},
"_drilldownQueries": {},
"_unites": [],
"_queries": {"coreA": {"term": {"field": "field", "value": "value"}, "type": "TermQuery"}},
"cores": ["coreA"],
"_filterQueries": {}
}, loads(self.post[0]['data']))
开发者ID:seecr,项目名称:meresco-lucene,代码行数:27,代码来源:multilucenetest.py
示例4: testJoinQueryOnOptionalKeyOtherSide
def testJoinQueryOnOptionalKeyOtherSide(self):
q = ComposedQuery('coreA')
q.setCoreQuery(core='coreB', query=luceneQueryFromCql('N=true'))
q.addMatch(dict(core='coreA', uniqueKey=KEY_PREFIX+'A'), dict(core='coreB', key=KEY_PREFIX+'D'))
result = returnValueFromGenerator(self.dna.any.executeComposedQuery(q))
self.assertEquals(1, result.total)
self.assertEquals(set(['A-M']), self.hitIds(result.hits))
开发者ID:jerryba,项目名称:meresco-lucene,代码行数:7,代码来源:multilucenetest.py
示例5: testJoinQueryWithFilters
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))
开发者ID:jerryba,项目名称:meresco-lucene,代码行数:7,代码来源:multilucenetest.py
示例6: testMultipleJoinQueriesKeepsCachesWithinMaxSize
def testMultipleJoinQueriesKeepsCachesWithinMaxSize(self):
for i in xrange(25):
self.addDocument(self.luceneB, identifier=str(i), keys=[('X', i)], fields=[('Y', str(i))])
for i in xrange(25):
q = ComposedQuery('coreA', query=MatchAllDocsQuery())
q.setCoreQuery(core='coreB', query=luceneQueryFromCql('Y=%s' % i))
q.addMatch(dict(core='coreA', uniqueKey=KEY_PREFIX+'A'), dict(core='coreB', key=KEY_PREFIX+'X'))
ignoredResult = returnValueFromGenerator(self.dna.any.executeComposedQuery(q))
开发者ID:jerryba,项目名称:meresco-lucene,代码行数:8,代码来源:multilucenetest.py
示例7: testKeyNamesDifferPerCore
def testKeyNamesDifferPerCore(self):
cq = ComposedQuery('coreA')
cq.addMatch(dict(core='coreA', uniqueKey='keyA'), dict(core='coreB', key='keyB'))
cq.addMatch(dict(core='coreA', uniqueKey='keyAC'), dict(core='coreC', key='keyC'))
cq.addFacet(core='coreB', facet='F0')
cq.addFacet(core='coreC', facet='F1')
self.assertEquals('keyAC', cq.keyName('coreA', 'coreC'))
self.assertEquals('keyC', cq.keyName('coreC', 'coreA'))
self.assertEquals(set(['keyA', 'keyAC']), cq.keyNames('coreA'))
开发者ID:FashtimeDotCom,项目名称:meresco-lucene,代码行数:9,代码来源:composedquerytest.py
示例8: testUniteMakesItTwoCoreQuery
def testUniteMakesItTwoCoreQuery(self):
cq = ComposedQuery('coreA')
cq.addMatch(dict(core='coreA', uniqueKey='keyA'), dict(core='coreB', key='keyB'))
cq.setCoreQuery('coreA', query='A')
cq.addUnite(dict(core='coreA', query='Q5'), dict(core='coreB', query='Q6'))
cq.validate()
self.assertEquals(set(['coreA', 'coreB']), cq.cores)
开发者ID:FashtimeDotCom,项目名称:meresco-lucene,代码行数:7,代码来源:composedquerytest.py
示例9: testIsSingleCoreQuery
def testIsSingleCoreQuery(self):
cq = ComposedQuery('coreA')
cq.addMatch(dict(core='coreA', uniqueKey='keyA'), dict(core='coreB', key='keyB'))
cq.setCoreQuery('coreA', query='A')
self.assertTrue(cq.isSingleCoreQuery())
cq.addUnite(dict(core='coreA', query='Q5'), dict(core='coreB', query='Q6'))
self.assertFalse(cq.isSingleCoreQuery())
开发者ID:FashtimeDotCom,项目名称:meresco-lucene,代码行数:7,代码来源:composedquerytest.py
示例10: testConvertComposedQuery
def testConvertComposedQuery(self):
q = ComposedQuery('A')
q.setCoreQuery(core='A', query=parseString('valueAQ'))
q.setCoreQuery(core='B', query=parseString('valueBQ'))
q.addMatch(dict(core='A', uniqueKey='keyA'), dict(core='B', key='keyB'))
q.addUnite(dict(core='A', query=parseString('fieldUA exact valueUA')), dict(core='B', query=parseString('fieldUB exact valueUB')))
q.validate()
consume(self.dna.any.executeComposedQuery(query=q))
self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
self.assertEquals(repr(TermQuery(Term('fieldA', 'valueaq'))), repr(q.queryFor('A')))
self.assertEquals(repr(TermQuery(Term('fieldB', 'valuebq'))), repr(q.queryFor('B')))
开发者ID:jerryba,项目名称:meresco-lucene,代码行数:11,代码来源:multicqltolucenequerytest.py
示例11: testAddRankQuery
def testAddRankQuery(self):
cq = ComposedQuery('coreA')
cq.setRankQuery('coreB', 'qB')
self.assertValidateRaisesValueError(cq, "No match set for cores ('coreA', 'coreB')")
cq.addMatch(dict(core='coreA', uniqueKey='kA'), dict(core='coreB', key='kB'))
self.assertEquals('qB', cq.rankQueryFor('coreB'))
cq.convertWith(coreB=lambda q: "converted_" + q)
self.assertEquals('converted_qB', cq.rankQueryFor('coreB'))
开发者ID:FashtimeDotCom,项目名称:meresco-lucene,代码行数:8,代码来源:composedquerytest.py
示例12: testAddDrilldownQuery
def testAddDrilldownQuery(self):
cq = ComposedQuery('coreA')
cq.addDrilldownQuery('coreB', ('field', ['value']))
self.assertValidateRaisesValueError(cq, "No match set for cores ('coreA', 'coreB')")
cq.addMatch(dict(core='coreA', uniqueKey='kA'), dict(core='coreB', key='kB'))
self.assertEquals([('field', ['value'])], cq.drilldownQueriesFor('coreB'))
cq.convertWith(coreB=lambda q: "converted_" + q)
self.assertEquals([('field', ['value'])], cq.drilldownQueriesFor('coreB'))
开发者ID:FashtimeDotCom,项目名称:meresco-lucene,代码行数:8,代码来源:composedquerytest.py
示例13: testAddOtherCoreFacetFilter
def testAddOtherCoreFacetFilter(self):
cq = ComposedQuery('coreA')
cq.addOtherCoreFacetFilter('coreB', 'field=value')
self.assertValidateRaisesValueError(cq, "No match set for cores ('coreA', 'coreB')")
cq.addMatch(dict(core='coreA', uniqueKey='kA'), dict(core='coreB', key='kB'))
self.assertEquals(['field=value'], cq.otherCoreFacetFiltersFor('coreB'))
cq.convertWith(coreB=lambda q: "converted_" + q)
self.assertEquals(['converted_field=value'], cq.otherCoreFacetFiltersFor('coreB'))
开发者ID:FashtimeDotCom,项目名称:meresco-lucene,代码行数:8,代码来源:composedquerytest.py
示例14: testUniteResultFromTwoIndexes
def testUniteResultFromTwoIndexes(self):
q = ComposedQuery('coreA')
q.setCoreQuery(core='coreA', query=luceneQueryFromCql('Q=true'))
q.setCoreQuery(core='coreB', query=None)
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))
开发者ID:jerryba,项目名称:meresco-lucene,代码行数:9,代码来源:multilucenetest.py
示例15: testUniteResultFromTwoIndexesCachedAfterUpdate
def testUniteResultFromTwoIndexesCachedAfterUpdate(self):
q = ComposedQuery('coreA')
q.setCoreQuery(core='coreA', query=luceneQueryFromCql('Q=true'), facets=[
dict(fieldname='cat_Q', maxTerms=10),
dict(fieldname='cat_U', maxTerms=10),
])
q.setCoreQuery(core='coreB', query=None, facets=[
dict(fieldname='cat_N', maxTerms=10),
dict(fieldname='cat_O', maxTerms=10),
])
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')))
resultOne = returnValueFromGenerator(self.dna.any.executeComposedQuery(q))
self.assertEquals(3, resultOne.total)
self.assertEquals([{
'terms': [
{'count': 3, 'term': u'true'}
], 'path': [], 'fieldname': u'cat_Q'
}, {
'terms': [
{'count': 2, 'term': u'true'},
{'count': 1, 'term': u'false'}
], 'path': [], 'fieldname': u'cat_U'
}, {
'terms': [
{'count': 2, 'term': u'true'}
], 'path': [], 'fieldname': u'cat_N'
}, {
'terms': [
{'count': 1, 'term': u'true'},
{'count': 1, 'term': u'false'},
], 'path': [], 'fieldname': u'cat_O'
}], resultOne.drilldownData)
self.addDocument(self.luceneA, identifier='A-MQU', keys=[('A', 8 )], fields=[('M', 'true' ), ('Q', 'false' ), ('U', 'true' ), ('S', '8')])
resultAgain = returnValueFromGenerator(self.dna.any.executeComposedQuery(q))
self.assertEquals(2, resultAgain.total)
self.assertEquals([{
'terms': [
{'count': 2, 'term': u'true'}
], 'path': [], 'fieldname': u'cat_Q'
}, {
'terms': [
{'count': 1, 'term': u'false'},
{'count': 1, 'term': u'true'},
], 'path': [], 'fieldname': u'cat_U'
}, {
'terms': [
{'count': 1, 'term': u'true'}
], 'path': [], 'fieldname': u'cat_N'
}, {
'terms': [
{'count': 1, 'term': u'true'}
], 'path': [], 'fieldname': u'cat_O'
}], resultAgain.drilldownData)
开发者ID:jerryba,项目名称:meresco-lucene,代码行数:56,代码来源:multilucenetest.py
示例16: testConvertComposedQuery
def testConvertComposedQuery(self):
q = ComposedQuery('A')
q.setCoreQuery(core='A', query=cqlToExpression('valueAQ'))
q.setCoreQuery(core='B', query=cqlToExpression('valueBQ'))
q.addMatch(dict(core='A', uniqueKey='keyA'), dict(core='B', key='keyB'))
q.addUnite(dict(core='A', query=cqlToExpression('fieldUA exact valueUA')), dict(core='B', query=cqlToExpression('fieldUB exact valueUB')))
q.validate()
consume(self.dna.any.executeComposedQuery(query=q))
self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
self.assertEquals("{'type': 'TermQuery', 'term': {'field': 'fieldA', 'value': u'valueaq'}, 'boost': 1.0}", repr(q.queryFor('A')))
self.assertEquals("{'type': 'TermQuery', 'term': {'field': 'fieldB', 'value': u'valuebq'}, 'boost': 1.0}", repr(q.queryFor('B')))
开发者ID:FashtimeDotCom,项目名称:meresco-lucene,代码行数:11,代码来源:adaptertolucenequerytest.py
示例17: testScoreCollectorCacheInvalidation
def testScoreCollectorCacheInvalidation(self):
q = ComposedQuery('coreA', query=MatchAllDocsQuery())
q.setRankQuery(core='coreC', query=luceneQueryFromCql('S=true'))
q.addMatch(dict(core='coreA', uniqueKey=KEY_PREFIX+'A'), dict(core='coreC', key=KEY_PREFIX+'C'))
result = returnValueFromGenerator(self.dna.any.executeComposedQuery(q))
self.assertEquals(8, result.total)
self.assertEquals(u'A-MQU', result.hits[0].id)
self.assertEquals(set([u'A', u'A-U', u'A-Q', u'A-QU', u'A-M', u'A-MU', u'A-MQ']), set([hit.id for hit in result.hits[1:]]))
self.addDocument(self.luceneC, identifier='C-S>A-MQ', keys=[('C', 7)], fields=[('S', 'true')])
try:
result = returnValueFromGenerator(self.dna.any.executeComposedQuery(q))
self.assertEquals(8, result.total)
self.assertEquals(set([u'A-MQ' , u'A-MQU']), set([hit.id for hit in result.hits[:2]]))
self.assertEquals(set([u'A', u'A-U', u'A-Q', u'A-QU', u'A-M', u'A-MU']), set([hit.id for hit in result.hits[2:]]))
finally:
self.luceneC.delete(identifier='C-S>A-MQ')
开发者ID:jerryba,项目名称:meresco-lucene,代码行数:17,代码来源:multilucenetest.py
示例18: testValidateComposedQuery
def testValidateComposedQuery(self):
composedQuery = ComposedQuery('coreA')
composedQuery.setCoreQuery(core='coreA', query='Q0')
composedQuery.setCoreQuery(core='coreB', query='Q1')
self.assertValidateRaisesValueError(composedQuery, "No match set for cores ('coreA', 'coreB')")
composedQuery = ComposedQuery('coreA', query="A")
composedQuery.addMatch(dict(core='coreA', uniqueKey='keyA'), dict(core='coreB', key='keyB'))
composedQuery.validate()
self.assertEquals(1, composedQuery.numberOfUsedCores)
开发者ID:FashtimeDotCom,项目名称:meresco-lucene,代码行数:10,代码来源:composedquerytest.py
示例19: testUnite
def testUnite(self):
cq = ComposedQuery('coreA')
cq.setCoreQuery(core='coreA', query=None)
cq.setCoreQuery(core='coreB', query=None)
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([('coreA', 'AQuery'), ('coreB', 'anotherQuery')], cq.unites)
开发者ID:jerryba,项目名称:meresco-lucene,代码行数:7,代码来源:composedquerytest.py
示例20: testRemoteExecuteQuery
def testRemoteExecuteQuery(self):
http = CallTrace('http')
def httppost(*args, **kwargs):
raise StopIteration('HTTP/1.0 200 Ok\r\n\r\n%s' % LuceneResponse(total=5, hits=[Hit("1"), Hit("2"), Hit("3", duplicateCount=2), Hit("4"), Hit("5")]).asJson())
yield
http.methods['httppost'] = httppost
remote = LuceneRemote(host='host', port=1234, path='/path')
observable = Observable()
observable.addObserver(remote)
remote._httppost = http.httppost
cq = ComposedQuery('coreA')
cq.setCoreQuery(
core='coreA',
query=parseString('query AND field=value'),
filterQueries=[parseString('query=fiets')],
facets=[{'fieldname': 'field', 'maxTerms':5}],
)
cq.setCoreQuery(core='coreB', query=parseString('query=test'))
cq.addMatch(dict(core='coreA', uniqueKey='keyA'), dict(core='coreB', key='keyB'))
result = returnValueFromGenerator(observable.any.executeComposedQuery(query=cq))
self.assertEquals(5, result.total)
self.assertEquals([Hit("1"), Hit("2"), Hit("3", duplicateCount=2), Hit("4"), Hit("5")], result.hits)
self.assertEquals(['httppost'], http.calledMethodNames())
m = http.calledMethods[0]
self.assertEquals('host', m.kwargs['host'])
self.assertEquals(1234, m.kwargs['port'])
self.assertEquals('/path/__lucene_remote__', m.kwargs['request'])
self.assertEquals('application/json', m.kwargs['headers']['Content-Type'])
message, kwargs = Conversion().jsonLoadMessage(m.kwargs['body'])
query = kwargs['query']
self.assertEquals('executeComposedQuery', message)
self.assertEquals('coreA', query.resultsFrom)
self.assertEquals([{'fieldname': 'field', 'maxTerms':5}], query.facetsFor('coreA'))
开发者ID:FashtimeDotCom,项目名称:meresco-lucene,代码行数:35,代码来源:luceneremotetest.py
注:本文中的meresco.lucene.composedquery.ComposedQuery类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论