本文整理汇总了Python中meresco.lucene.composedquery.ComposedQuery.relationalFilter方法的典型用法代码示例。如果您正苦于以下问题:Python ComposedQuery.relationalFilter方法的具体用法?Python ComposedQuery.relationalFilter怎么用?Python ComposedQuery.relationalFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meresco.lucene.composedquery.ComposedQuery
的用法示例。
在下文中一共展示了ComposedQuery.relationalFilter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testAsDictFromDict
# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import relationalFilter [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.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.clustering = True
cq.clusteringConfig = {'clusteringEps': 0.2}
cq.rankQueryScoreRatio = 0.75
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('{"type": "madeUpJoinQuery"}', cq2.relationalFilter)
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)
self.assertEquals(0.75, cq2.rankQueryScoreRatio)
示例2: testRepr
# 需要导入模块: from meresco.lucene.composedquery import ComposedQuery [as 别名]
# 或者: from meresco.lucene.composedquery.ComposedQuery import relationalFilter [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())