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