コード例 #1
0
 def testXTermDrilldown(self):
     self.response = LuceneResponse(drilldownData=[
             dict(fieldname='prefix:field1', terms=[dict(term='term1', count=1)]),
             dict(fieldname='unknownJoinName.field', terms=[]),
             dict(fieldname='normal:drilldown', terms=[]),
             dict(fieldname='prefix:field2', terms=[dict(term='term2', count=1)]),
         ])
     response = retval(self.tree.any.executeQuery(
             cqlAbstractSyntaxTree=parseCQL('*'),
             extraArguments={},
             facets=[
                 dict(fieldname='otherCore.prefix:field2', maxTerms=7),
                 dict(fieldname='normal:drilldown', maxTerms=11),
                 dict(fieldname='otherCore.prefix:field1', maxTerms=9),
                 dict(fieldname='unknownJoinName.field', maxTerms=12)
             ],
             someKwarg='someValue'))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     cq.validate()
     self.assertEquals(set(['defaultCore', 'otherCore']), cq.cores)
     self.assertEquals('keyDefault', cq.keyName('defaultCore', 'otherCore'))
     self.assertEquals('keyOther', cq.keyName('otherCore', 'defaultCore'))
     self.assertEquals([dict(fieldname='prefix:field2', path=[], maxTerms=7), dict(fieldname='prefix:field1', path=[], maxTerms=9)], cq.facetsFor('otherCore'))
     self.assertEquals([dict(fieldname='normal:drilldown', path=[], maxTerms=11), dict(fieldname='unknownJoinName.field', path=[], maxTerms=12)], cq.facetsFor('defaultCore'))
     self.assertEquals([
             dict(fieldname='otherCore.prefix:field2', terms=[dict(term='term2', count=1)]),
             dict(fieldname='normal:drilldown', terms=[]),
             dict(fieldname='otherCore.prefix:field1', terms=[dict(term='term1', count=1)]),
             dict(fieldname='unknownJoinName.field', terms=[])
         ], response.drilldownData)
コード例 #2
0
 def testXTermDrilldown(self):
     self.response = LuceneResponse(drilldownData=[
             dict(fieldname='prefix:field1', terms=[dict(term='term1', count=1)]),
             dict(fieldname='unknownJoinName.field', terms=[]),
             dict(fieldname='normal:drilldown', terms=[]),
             dict(fieldname='prefix:field2', terms=[dict(term='term2', count=1)]),
         ])
     response = retval(self.tree.any.executeQuery(
             cqlAbstractSyntaxTree=parseCQL('*'),
             extraArguments={},
             facets=[
                 dict(fieldname='otherCore.prefix:field2', maxTerms=7),
                 dict(fieldname='normal:drilldown', maxTerms=11),
                 dict(fieldname='otherCore.prefix:field1', maxTerms=9),
                 dict(fieldname='unknownJoinName.field', maxTerms=12)
             ],
             someKwarg='someValue'))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     cq.validate()
     self.assertEquals(set(['defaultCore', 'otherCore']), cq.cores)
     self.assertEquals('keyDefault', cq.keyName('defaultCore', 'otherCore'))
     self.assertEquals('keyOther', cq.keyName('otherCore', 'defaultCore'))
     self.assertEquals([dict(fieldname='prefix:field2', path=[], maxTerms=7), dict(fieldname='prefix:field1', path=[], maxTerms=9)], cq.facetsFor('otherCore'))
     self.assertEquals([dict(fieldname='normal:drilldown', path=[], maxTerms=11), dict(fieldname='unknownJoinName.field', path=[], maxTerms=12)], cq.facetsFor('defaultCore'))
     self.assertEquals([
             dict(fieldname='otherCore.prefix:field2', terms=[dict(term='term2', count=1)]),
             dict(fieldname='normal:drilldown', terms=[]),
             dict(fieldname='otherCore.prefix:field1', terms=[dict(term='term1', count=1)]),
             dict(fieldname='unknownJoinName.field', terms=[])
         ], response.drilldownData)
コード例 #3
0
 def testDrilldownQueriesWithTranslate(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={}, drilldownQueries=[('toBePrefixed', ['path1', 'path2']), ('otherCore.toBePrefixed', ['path3'])]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     cq.validate()
     self.assertEquals([('prefix.toBePrefixed', ['path1', 'path2'])], cq.drilldownQueriesFor('defaultCore'))
     self.assertEquals([('prefix.toBePrefixed', ['path3'])], cq.drilldownQueriesFor('otherCore'))
コード例 #4
0
 def testXFilterCommonKeysFieldOverridesXFilterCommonKeys(self):
     self.setupDna(dedupByDefault=False)
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={'x-filter-common-keys-field': ['dcterms:isFormatOf.uri'], 'x-filter-common-keys': ['true']}, facets=[]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertEquals("__key__.dcterms:isFormatOf.uri", cq.dedupField)
     self.assertEquals("__key__.date", cq.dedupSortField)
コード例 #5
0
 def testDedupExplicitlyOn(self):
     self.setupDna(dedupByDefault=False)
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={'x-filter-common-keys': ['true']}, facets=[]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertEquals("__key__.dedup", cq.dedupField)
     self.assertEquals("__key__.date", cq.dedupSortField)
コード例 #6
0
 def testDedupExplicitlyOn(self):
     self.setupDna(dedupByDefault=False)
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={'x-filter-common-keys': ['true']}, facets=[]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertEquals("__key__", cq.dedupField)
     self.assertEquals("__key__.date", cq.dedupSortField)
コード例 #7
0
 def testNoDedupWhenDedupByDefaultSetToFalse(self):
     self.setupDna(dedupByDefault=False)
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={}, facets=[]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertEquals(None, cq.dedupField)
     self.assertEquals(None, cq.dedupSortField)
コード例 #8
0
 def testNoDedupWhenDedupByDefaultSetToFalse(self):
     self.setupDna(dedupByDefault=False)
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={}, facets=[]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertEquals(None, cq.dedupField)
     self.assertEquals(None, cq.dedupSortField)
コード例 #9
0
 def testDrilldownQueriesWithTranslate(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={}, drilldownQueries=[('toBePrefixed', ['path1', 'path2']), ('otherCore.toBePrefixed', ['path3'])]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     cq.validate()
     self.assertEquals([('prefix.toBePrefixed', ['path1', 'path2'])], cq.drilldownQueriesFor('defaultCore'))
     self.assertEquals([('prefix.toBePrefixed', ['path3'])], cq.drilldownQueriesFor('otherCore'))
コード例 #10
0
 def testNormalQueryWithoutAnyJoin(self):
     ast = parseCQL("prefixfield=value")
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=ast, extraArguments={}))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     cq.validate()
     self.assertEquals('defaultCore', cq.resultsFrom)
     self.assertEquals([cqlToExpression("prefixfield=value")], cq.queriesFor('defaultCore'))
コード例 #11
0
 def testXFilterWhichIsNoJoinQuery(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={'x-filter': ['prefix:field=value']}, facets=[], someKwarg='someValue'))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     cq.validate()
     self.assertEquals('defaultCore', cq.resultsFrom)
     self.assertEquals([cqlToExpression("*"), cqlToExpression("prefix:field=value")], cq.queriesFor('defaultCore'))
     self.assertEquals(1, cq.numberOfUsedCores)
コード例 #12
0
 def testXFilterCommonKeysIgnoredWhenNoDedupFieldSpecified(self):
     self.setupDna(dedupFieldName=None)
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'),
             extraArguments={'x-filter-common-keys': []}, facets=[]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertEquals(None, cq.dedupField)
     self.assertEquals(None, cq.dedupSortField)
コード例 #13
0
 def testXFilterCommonKeysIgnoredWhenNoDedupFieldSpecified(self):
     self.setupDna(dedupFieldName=None)
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'),
             extraArguments={'x-filter-common-keys': []}, facets=[]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertEquals(None, cq.dedupField)
     self.assertEquals(None, cq.dedupSortField)
コード例 #14
0
 def testXFilterWhichIsNoJoinQuery(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={'x-filter': ['prefix:field=value']}, facets=[], someKwarg='someValue'))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     cq.validate()
     self.assertEquals('defaultCore', cq.resultsFrom)
     self.assertEquals([cqlToExpression("*"), cqlToExpression("prefix:field=value")], cq.queriesFor('defaultCore'))
     self.assertEquals(1, cq.numberOfUsedCores)
コード例 #15
0
 def testNormalQueryWithoutAnyJoin(self):
     ast = parseCQL("prefixfield=value")
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=ast, extraArguments={}))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     cq.validate()
     self.assertEquals('defaultCore', cq.resultsFrom)
     self.assertEquals([cqlToExpression("prefixfield=value")], cq.queriesFor('defaultCore'))
コード例 #16
0
 def testTwoXFiltersForSameCore(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={'x-filter': ['otherCore.prefix:field=value', 'otherCore.field2=value2']}, facets=[]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     cq.validate()
     self.assertEquals('defaultCore', cq.resultsFrom)
     self.assertEquals(set(['defaultCore', 'otherCore']), cq.cores)
     self.assertEquals('keyDefault', cq.keyName('defaultCore', 'otherCore'))
     self.assertEquals('keyOther', cq.keyName('otherCore', 'defaultCore'))
     self.assertEquals([cqlToExpression("prefix:field=value"), cqlToExpression('field2=value2')], cq.queriesFor('otherCore'))
コード例 #17
0
 def testTwoXFiltersForSameCore(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={'x-filter': ['otherCore.prefix:field=value', 'otherCore.field2=value2']}, facets=[]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     cq.validate()
     self.assertEquals('defaultCore', cq.resultsFrom)
     self.assertEquals(set(['defaultCore', 'otherCore']), cq.cores)
     self.assertEquals('keyDefault', cq.keyName('defaultCore', 'otherCore'))
     self.assertEquals('keyOther', cq.keyName('otherCore', 'defaultCore'))
     self.assertEquals([cqlToExpression("prefix:field=value"), cqlToExpression('field2=value2')], cq.queriesFor('otherCore'))
コード例 #18
0
 def testFilterQuery(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), filterQueries=[('otherCore', 'prefix:field=value')], facets=[], start=1))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     cq.validate()
     self.assertEquals(1, cq.start)
     self.assertEquals(set(['defaultCore', 'otherCore']), cq.cores)
     self.assertEquals('keyDefault', cq.keyName('defaultCore', 'otherCore'))
     self.assertEquals('keyOther', cq.keyName('otherCore', 'defaultCore'))
     self.assertEquals([cqlToExpression("prefix:field=value")], cq.queriesFor('otherCore'))
     self.assertEquals([cqlToExpression('*')], cq.queriesFor('defaultCore'))
コード例 #19
0
 def testFilterQuery(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), filterQueries=[('otherCore', 'prefix:field=value')], facets=[], start=1))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     cq.validate()
     self.assertEquals(1, cq.start)
     self.assertEquals(set(['defaultCore', 'otherCore']), cq.cores)
     self.assertEquals('keyDefault', cq.keyName('defaultCore', 'otherCore'))
     self.assertEquals('keyOther', cq.keyName('otherCore', 'defaultCore'))
     self.assertEquals([cqlToExpression("prefix:field=value")], cq.queriesFor('otherCore'))
     self.assertEquals([cqlToExpression('*')], cq.queriesFor('defaultCore'))
コード例 #20
0
 def testSortKeys(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), sortKeys=[dict(sortBy='field', sortDescending=True), dict(sortBy='otherCore.field', sortDescending=False)]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     cq.validate()
     self.assertEquals(set(['defaultCore', 'otherCore']), cq.cores)
     self.assertEquals('keyDefault', cq.keyName('defaultCore', 'otherCore'))
     self.assertEquals('keyOther', cq.keyName('otherCore', 'defaultCore'))
     self.assertEquals([
             dict(sortBy='field', sortDescending=True, core='defaultCore'),
             dict(sortBy='field', sortDescending=False, core='otherCore')
         ], cq.sortKeys)
コード例 #21
0
 def testSortKeys(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), sortKeys=[dict(sortBy='field', sortDescending=True), dict(sortBy='otherCore.field', sortDescending=False)]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     cq.validate()
     self.assertEquals(set(['defaultCore', 'otherCore']), cq.cores)
     self.assertEquals('keyDefault', cq.keyName('defaultCore', 'otherCore'))
     self.assertEquals('keyOther', cq.keyName('otherCore', 'defaultCore'))
     self.assertEquals([
             dict(sortBy='field', sortDescending=True, core='defaultCore'),
             dict(sortBy='field', sortDescending=False, core='otherCore')
         ], cq.sortKeys)
コード例 #22
0
 def testXRankQuery(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={'x-rank-query': ['otherCore.prefix:field=value', 'otherCore.otherprefix:otherfield=othervalue', 'field=value']}))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     cq.validate()
     self.assertEquals(set(['defaultCore', 'otherCore']), cq.cores)
     self.assertEquals('keyDefault', cq.keyName('defaultCore', 'otherCore'))
     self.assertEquals('keyOther', cq.keyName('otherCore', 'defaultCore'))
     self.assertEquals(cqlToExpression("prefix:field=value OR otherprefix:otherfield=othervalue"), cq.rankQueryFor('otherCore'))
     self.assertEquals(cqlToExpression("field=value"), cq.rankQueryFor('defaultCore'))
     self.assertEquals([], cq.queriesFor('otherCore'))
     self.assertEquals([cqlToExpression('*')], cq.queriesFor('defaultCore'))
コード例 #23
0
 def testXRankQuery(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={'x-rank-query': ['otherCore.prefix:field=value', 'otherCore.otherprefix:otherfield=othervalue', 'field=value']}))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     cq.validate()
     self.assertEquals(set(['defaultCore', 'otherCore']), cq.cores)
     self.assertEquals('keyDefault', cq.keyName('defaultCore', 'otherCore'))
     self.assertEquals('keyOther', cq.keyName('otherCore', 'defaultCore'))
     self.assertEquals(cqlToExpression("prefix:field=value OR otherprefix:otherfield=othervalue"), cq.rankQueryFor('otherCore'))
     self.assertEquals(cqlToExpression("field=value"), cq.rankQueryFor('defaultCore'))
     self.assertEquals([], cq.queriesFor('otherCore'))
     self.assertEquals([cqlToExpression('*')], cq.queriesFor('defaultCore'))
コード例 #24
0
 def testMatchesOptional(self):
     self.tree = be(
         (Observable(),
             (ConvertToComposedQuery(resultsFrom='defaultCore'),
                 (self.observer,)
             )
         )
     )
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={'x-filter': ['prefix:field=value']}, facets=[], start=1))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     cq.validate()
     self.assertEquals(1, cq.start)
     self.assertEquals(set(['defaultCore']), cq.cores)
     self.assertRaises(KeyError, lambda: cq.keyName('defaultCore', 'otherCore'))
     self.assertEquals([cqlToExpression("*"), cqlToExpression("prefix:field=value")], cq.queriesFor('defaultCore'))
コード例 #25
0
 def testMatchesOptional(self):
     self.tree = be(
         (Observable(),
             (ConvertToComposedQuery(resultsFrom='defaultCore'),
                 (self.observer,)
             )
         )
     )
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={'x-filter': ['prefix:field=value']}, facets=[], start=1))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     cq.validate()
     self.assertEquals(1, cq.start)
     self.assertEquals(set(['defaultCore']), cq.cores)
     self.assertRaises(KeyError, lambda: cq.keyName('defaultCore', 'otherCore'))
     self.assertEquals([cqlToExpression("*"), cqlToExpression("prefix:field=value")], cq.queriesFor('defaultCore'))
コード例 #26
0
    def testHierarchicalXTermDrilldown(self):
        self.response = LuceneResponse(drilldownData=[
            dict(fieldname='field1', path=['field2'], terms=[dict(term='term1', count=1)]),
        ])

        response = retval(self.tree.any.executeQuery(
            cqlAbstractSyntaxTree=parseCQL('*'),
            extraArguments={},
            facets=[
                dict(fieldname='otherCore.field1>field2', maxTerms=10),
            ],
            someKwarg='someValue'))
        self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
        cq = self.observer.calledMethods[0].kwargs['query']
        cq.validate()
        self.assertEquals([{'fieldname': 'field1', 'path': ['field2'], 'maxTerms': 10}], cq.facetsFor('otherCore'))
        self.assertEquals([
            dict(fieldname='otherCore.field1', path=['field2'], terms=[dict(term='term1', count=1)]),
        ], response.drilldownData)
コード例 #27
0
    def testHierarchicalXTermDrilldown(self):
        self.response = LuceneResponse(drilldownData=[
            dict(fieldname='field1', path=['field2'], terms=[dict(term='term1', count=1)]),
        ])

        response = retval(self.tree.any.executeQuery(
            cqlAbstractSyntaxTree=parseCQL('*'),
            extraArguments={},
            facets=[
                dict(fieldname='otherCore.field1>field2', maxTerms=10),
            ],
            someKwarg='someValue'))
        self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
        cq = self.observer.calledMethods[0].kwargs['query']
        cq.validate()
        self.assertEquals([{'fieldname': 'field1', 'path': ['field2'], 'maxTerms': 10}], cq.facetsFor('otherCore'))
        self.assertEquals([
            dict(fieldname='otherCore.field1', path=['field2'], terms=[dict(term='term1', count=1)]),
        ], response.drilldownData)
コード例 #28
0
 def testConvertJoinQueryToFilters(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('field=value AND otherCore.field=value2')))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertEqual(QueryExpression.searchterm('field', '=', 'value'), cq.queryFor('defaultCore'))
     self.assertEqual([QueryExpression.searchterm('field', '=', 'value2')], cq.filterQueriesFor('otherCore'))
コード例 #29
0
 def testDedup(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={}, facets=[]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertEquals("__key__.dedup", cq.dedupField)
     self.assertEquals("__key__.date", cq.dedupSortField)
コード例 #30
0
 def testIgnoreCorePrefixForResultCore(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('defaultCore.field=value')))
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertEqual([cqlToExpression('defaultCore.field=value')], cq.queriesFor('defaultCore'))
コード例 #31
0
 def testClustering(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={'x-clustering': ['true']}))
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertTrue(cq.clustering)
コード例 #32
0
 def testDedupTurnedOff(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={'x-filter-common-keys': ['false']}, facets=[]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertEquals(None, cq.dedupField)
     self.assertEquals(None, cq.dedupSortField)
コード例 #33
0
 def testClusteringNotEnabledIfTurnedOffInConfig(self):
     consume(self.tree.any.updateConfig(config=dict(features_disabled=['clustering']), indexConfig={}))
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('fiets'), extraArguments={'x-clustering': ['true']}, facets=[]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertEquals(None, cq.clusteringConfig)
コード例 #34
0
 def testGroupingTurnedOn(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('fiets'), extraArguments={'x-grouping': ['true']}, facets=[]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertEquals("__key__", cq.otherKwargs().get("groupingField"))
コード例 #35
0
 def testClustering(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={'x-clustering': ['true']}))
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertTrue(cq.clustering)
コード例 #36
0
 def testClusteringNotEnabledIfTurnedOffInConfig(self):
     consume(self.tree.any.updateConfig(config=dict(features_disabled=['clustering']), indexConfig={}))
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('fiets'), extraArguments={'x-clustering': ['true']}, facets=[]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertEquals(None, cq.clusteringConfig)
コード例 #37
0
 def testDedupTurnedOff(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={'x-filter-common-keys': ['false']}, facets=[]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertEquals(None, cq.dedupField)
     self.assertEquals(None, cq.dedupSortField)
コード例 #38
0
 def testIgnoreCorePrefixForResultCore(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('defaultCore.field=value')))
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertEqual([cqlToExpression('defaultCore.field=value')], cq.queriesFor('defaultCore'))
コード例 #39
0
 def testConvertJoinQueryToFilters(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('field=value AND otherCore.field=value2')))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertEqual(QueryExpression.searchterm('field', '=', 'value'), cq.queryFor('defaultCore'))
     self.assertEqual([QueryExpression.searchterm('field', '=', 'value2')], cq.filterQueriesFor('otherCore'))
コード例 #40
0
 def testNoGroupingForMatchAllQuery(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={'x-grouping': ['true']}))
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertEqual(None, cq.groupingField)
コード例 #41
0
 def testGroupingDefaultTurnedOff(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={}, facets=[]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertEquals(None, cq.otherKwargs().get("groupingField"))
コード例 #42
0
 def testDedup(self):
     consume(self.tree.any.executeQuery(cqlAbstractSyntaxTree=parseCQL('*'), extraArguments={}, facets=[]))
     self.assertEquals(['executeComposedQuery'], self.observer.calledMethodNames())
     cq = self.observer.calledMethods[0].kwargs['query']
     self.assertEquals("__key__", cq.dedupField)
     self.assertEquals("__key__.date", cq.dedupSortField)