当前位置: 首页>>代码示例>>Python>>正文


Python ComposedQuery.setCoreQuery方法代码示例

本文整理汇总了Python中meresco.lucene.composedquery.ComposedQuery.setCoreQuery方法的典型用法代码示例。如果您正苦于以下问题:Python ComposedQuery.setCoreQuery方法的具体用法?Python ComposedQuery.setCoreQuery怎么用?Python ComposedQuery.setCoreQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在meresco.lucene.composedquery.ComposedQuery的用法示例。


在下文中一共展示了ComposedQuery.setCoreQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testJoinQueryOnOptionalKeyOtherSide

# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import setCoreQuery [as 别名]
 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,代码行数:9,代码来源:multilucenetest.py

示例2: testComposedQuery

# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import setCoreQuery [as 别名]
    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,代码行数:29,代码来源:multilucenetest.py

示例3: testAsDictFromDict

# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import setCoreQuery [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)
开发者ID:FashtimeDotCom,项目名称:meresco-lucene,代码行数:31,代码来源:composedquerytest.py

示例4: testJoinQuery

# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import setCoreQuery [as 别名]
 def testJoinQuery(self):
     q = ComposedQuery('coreA', query=MatchAllDocsQuery())
     q.setCoreQuery(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, result.total)
     self.assertEquals(set(['A-M', 'A-MU', 'A-MQ', 'A-MQU']), self.hitIds(result.hits))
开发者ID:jerryba,项目名称:meresco-lucene,代码行数:9,代码来源:multilucenetest.py

示例5: testKeyName

# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import setCoreQuery [as 别名]
 def testKeyName(self):
     composedQuery = ComposedQuery('coreA')
     composedQuery.setCoreQuery(core='coreA', query=None)
     composedQuery.setCoreQuery(core='coreB', query=None)
     composedQuery.addMatch(dict(core='coreA', uniqueKey='keyA'), dict(core='coreB', key='keyB'))
     self.assertEquals('keyA', composedQuery.keyName('coreA'))
     self.assertEquals('keyB', composedQuery.keyName('coreB'))
开发者ID:jerryba,项目名称:meresco-lucene,代码行数:9,代码来源:composedquerytest.py

示例6: testRemoteExecuteQuery

# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import setCoreQuery [as 别名]
    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,代码行数:37,代码来源:luceneremotetest.py

示例7: testUnite

# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import setCoreQuery [as 别名]
 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,代码行数:9,代码来源:composedquerytest.py

示例8: testJoinFacetAndQuery

# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import setCoreQuery [as 别名]
 def testJoinFacetAndQuery(self):
     q = ComposedQuery('coreA')
     q.setCoreQuery(core='coreA', query=None)
     q.setCoreQuery(core='coreB', query=luceneQueryFromCql('N=true'), 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'))
     result = returnValueFromGenerator(self.dna.any.executeComposedQuery(query=q))
     self.assertEquals(4, result.total)
     self.assertEquals(set(['A-M', 'A-MU', 'A-MQ', 'A-MQU']), self.hitIds(result.hits))
     self.assertEquals([{
             'terms': [
                 {'count': 4, 'term': u'true'},
             ],
             'path': [],
             'fieldname': u'cat_N'
         }, {
             'terms': [
                 {'count': 2, 'term': u'true'},
                 {'count': 2, 'term': u'false'},
             ],
             'path': [],
             'fieldname': u'cat_O'
         }], result.drilldownData)
开发者ID:jerryba,项目名称:meresco-lucene,代码行数:27,代码来源:multilucenetest.py

示例9: testUniteResultFromTwoIndexesCached

# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import setCoreQuery [as 别名]
    def testUniteResultFromTwoIndexesCached(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))

        q = ComposedQuery('coreA')
        q.setCoreQuery(core='coreA', query=luceneQueryFromCql('U=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=false')), dict(core='coreB', query=luceneQueryFromCql('N=true')))
        ignoredResult = returnValueFromGenerator(self.dna.any.executeComposedQuery(q))

        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')))
        resultAgain = returnValueFromGenerator(self.dna.any.executeComposedQuery(q))
        self.assertEquals(resultOne.total, resultAgain.total)
        self.assertEquals(resultOne.hits, resultAgain.hits)
        self.assertEquals(resultOne.drilldownData, resultAgain.drilldownData)
开发者ID:jerryba,项目名称:meresco-lucene,代码行数:37,代码来源:multilucenetest.py

示例10: testIsSingleCoreQuery

# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import setCoreQuery [as 别名]
 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,代码行数:9,代码来源:composedquerytest.py

示例11: testAddTypeAndMissingValueToSortField

# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import setCoreQuery [as 别名]
    def testAddTypeAndMissingValueToSortField(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('coreB', q)
        cq.sortKeys = [dict(sortBy='sortField', core='coreA', sortDescending=True)]
        cq.addMatch(dict(core='coreA', uniqueKey='A'), dict(core='coreB', key='B'))
        consume(self._multiLucene.executeComposedQuery(cq))
        self.assertEqual({
                "_sortKeys": [{'core': 'coreA', 'sortBy': 'sortField', 'sortDescending': True, 'type': 'String', 'missingValue': 'STRING_FIRST'}],
                "resultsFrom": "coreA",
                '_matches': {'coreA->coreB': [{'core': 'coreA', 'uniqueKey': 'A'}, {'core': 'coreB', 'key': 'B'}]},
                "_facets": {},
                "_otherCoreFacetFilters": {},
                "_rankQueries": {},
                "_drilldownQueries": {},
                "_unites": [],
                '_queries': {'coreB': {'term': {'field': 'field', 'value': 'value'}, 'type': 'TermQuery'}},
                "cores": ["coreB", "coreA"],
                "_filterQueries": {}
            }, loads(self.post[0]['data']))
开发者ID:seecr,项目名称:meresco-lucene,代码行数:28,代码来源:multilucenetest.py

示例12: testUniteMakesItTwoCoreQuery

# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import setCoreQuery [as 别名]
 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,代码行数:9,代码来源:composedquerytest.py

示例13: testUniteMakesItTwoCoreQuery

# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import setCoreQuery [as 别名]
 def testUniteMakesItTwoCoreQuery(self):
     q = ComposedQuery('coreA')
     q.setCoreQuery(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))
开发者ID:jerryba,项目名称:meresco-lucene,代码行数:10,代码来源:multilucenetest.py

示例14: testMultipleJoinQueriesKeepsCachesWithinMaxSize

# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import setCoreQuery [as 别名]
 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,代码行数:10,代码来源:multilucenetest.py

示例15: testKeyFilterIgnoresKeysOutOfBoundsOfKeySet

# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import setCoreQuery [as 别名]
 def testKeyFilterIgnoresKeysOutOfBoundsOfKeySet(self):
     self.addDocument(self.luceneB, identifier=str(100), keys=[('B', 100)], fields=[]) # Force key to be much more than bits in long[] in FixedBitSet, so it must be OutOfBounds
     q = ComposedQuery('coreA')
     q.setCoreQuery(core='coreA', query=MatchAllDocsQuery())
     q.setCoreQuery(core='coreB', query=MatchAllDocsQuery())
     q.addFacet(core='coreB', facet=dict(fieldname='cat_M', maxTerms=10))
     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))
开发者ID:jerryba,项目名称:meresco-lucene,代码行数:11,代码来源:multilucenetest.py


注:本文中的meresco.lucene.composedquery.ComposedQuery.setCoreQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。