Esempio n. 1
0
 def testRemoteServiceWithBadCore(self):
     remote = SynchronousRemote(host='localhost',
                                port=self.httpPort,
                                path='/remote')
     self.assertRaises(
         IOError,
         lambda: remote.executeQuery(parseCql('*'), core='doesnotexist'))
Esempio n. 2
0
 def testJoin(self):
     remote = SynchronousRemote(host='localhost', port=self.httpPort, path='/remote')
     q = ComposedQuery('main', query=cqlToExpression('*'))
     q.addMatch(dict(core='main', uniqueKey=KEY_PREFIX+'field'), dict(core='main2', key=KEY_PREFIX+'field'))
     q.start=0
     q.stop=100
     q.addFilterQuery(core='main', query=cqlToExpression('field2=value0 OR field2=value1'))
     q.addFacet(core='main2', facet=dict(fieldname='untokenized.field2', maxTerms=5))
     response = remote.executeComposedQuery(query=q)
     self.assertEquals(19, response.total)
     self.assertEquals(set([
             'record:10', 'record:11', 'record:20', 'record:21', 'record:30',
             'record:31', 'record:40', 'record:41', 'record:50', 'record:51',
             'record:60', 'record:61', 'record:70', 'record:71', 'record:80',
             'record:81', 'record:90', 'record:91', 'record:100'
         ]), set([hit.id for hit in response.hits]))
     self.assertEquals([{
             'fieldname': 'untokenized.field2',
             'path': [],
             'terms': [
                 {'count': 27, 'term': 'value3'},
                 {'count': 22, 'term': 'value0'},
                 {'count': 19, 'term': 'value5'},
                 {'count': 19, 'term': 'value7'},
                 {'count': 19, 'term': 'value9'},
             ]
         }], response.drilldownData)
 def testGrouping(self):
     remote = SynchronousRemote(host='localhost', port=self.httpPort, path='/remote')
     response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('*'), groupingField="__key__.groupfield", core="main2", stop=3, sortKeys=[{'sortBy': '__id__', 'sortDescending': False}])
     self.assertEqual(3, len(response.hits))
     self.assertEquals(
         [('record:1', 100), ('record:100', 100), ('record:200', 100)],
         [(hit.id, len(hit.duplicates['__key__.groupfield'])) for hit in response.hits]
     )
Esempio n. 4
0
 def testJoinWithSortAndMissingValue(self):
     remote = SynchronousRemote(host='localhost', port=self.httpPort, path='/remote')
     q = ComposedQuery('main', query=cqlToExpression('*'))
     q.addMatch(dict(core='main', uniqueKey=KEY_PREFIX+'field'), dict(core='main2', key=KEY_PREFIX+'field'))
     q.addFacet(core='main2', facet=dict(fieldname='untokenized.field2', maxTerms=5))
     q.addSortKey(dict(core="main", sortBy="sorted.field4", sortDescending=True))
     response = remote.executeComposedQuery(query=q)
     self.assertEqual("record:1", response.hits[0].id)
     del q._sortKeys[:]
     q.addSortKey(dict(core="main", sortBy="sorted.field4", sortDescending=False))
     response = remote.executeComposedQuery(query=q)
     self.assertEqual("record:1", response.hits[0].id)
    def testDedup(self):
        remote = SynchronousRemote(host='localhost', port=self.httpPort, path='/remote')
        response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('*'), dedupField="__key__.field", core="main", stop=3, sortKeys=[{'sortBy': '__id__', 'sortDescending': False}])
        self.assertEqual(100, response.total)
        self.assertEqual(100, response.totalWithDuplicates)
        self.assertEquals(
            [('record:1', 1), ('record:10', 1), ('record:100', 1)],
            [(hit.id, hit.duplicateCount['__key__.field']) for hit in response.hits]
        )

        response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('*'), dedupField="__key__.groupfield", dedupSortField="__id__", core="main2", stop=3, sortKeys=[{'sortBy': '__id__', 'sortDescending': False}])
        self.assertEqual(10, response.total)
        self.assertEqual(1000, response.totalWithDuplicates)
        self.assertEquals(
            [100] * 3,
            [hit.duplicateCount['__key__.groupfield'] for hit in response.hits]
        )
Esempio n. 6
0
    def testDedup(self):
        remote = SynchronousRemote(host='localhost',
                                   port=self.httpPort,
                                   path='/remote')
        response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('*'),
                                       dedupField="__key__.field",
                                       core="main",
                                       stop=3,
                                       sortKeys=[{
                                           'sortBy': '__id__',
                                           'sortDescending': False
                                       }])

        self.assertEquals([('record:1', 0), ('record:10', 1),
                           ('record:100', 1)],
                          [(hit.id, hit.duplicateCount['__key__.field'])
                           for hit in response.hits])
Esempio n. 7
0
    def testDedup(self):
        remote = SynchronousRemote(host='localhost', port=self.httpPort, path='/remote')
        response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('*'), dedupField="__key__.field", core="main", stop=3)
        self.assertEqual(100, response.total)
        self.assertEqual(100, response.totalWithDuplicates)
        self.assertEquals(
            [1, 1, 1],
            [hit.duplicateCount['__key__.field'] for hit in response.hits]
        )

        response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('*'), dedupField="__key__.groupfield", dedupSortField="__id__", core="main2", stop=3)
        self.assertEqual(10, response.total)
        self.assertEqual(1000, response.totalWithDuplicates)
        self.assertEquals(
            [100] * 3,
            [hit.duplicateCount['__key__.groupfield'] for hit in response.hits]
        )
Esempio n. 8
0
    def testDedup(self):
        remote = SynchronousRemote(host='localhost', port=self.httpPort, path='/remote')
        response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('*'), dedupField="__key__.field", core="main", stop=3)
        self.assertEqual(100, response.total)
        self.assertEqual(100, response.totalWithDuplicates)
        self.assertEquals(
            [1, 1, 1],
            [hit.duplicateCount['__key__.field'] for hit in response.hits]
        )

        response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('*'), dedupField="__key__.groupfield", dedupSortField="__id__", core="main2", stop=3)
        self.assertEqual(3, len(response.hits))
        self.assertEqual(10, response.total)
        self.assertEqual(1000, response.totalWithDuplicates)
        self.assertEquals(
            [100] * 3,
            [hit.duplicateCount['__key__.groupfield'] for hit in response.hits]
        )

        response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('*'), dedupField="__key__.groupfield", dedupSortField="__numeric__.sort1", core="main2", stop=100000)
        self.assertEqual(10, len(response.hits))
        self.assertEqual(10, response.total)
        self.assertEqual(1000, response.totalWithDuplicates)
        self.assertEquals(
            [100] * 10,
            [hit.duplicateCount['__key__.groupfield'] for hit in response.hits]
        )

        response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('groupfield=1'), dedupField="__key__.groupfield", dedupSortField=["__numeric__.sort1","__numeric__.sort2"], core="main2", stop=10000)
        self.assertEqual(1, len(response.hits))
        self.assertEqual(1, response.total)
        self.assertEqual(100, response.totalWithDuplicates)
        self.assertEquals(['main2:record:199'], [hit.id for hit in response.hits]
        )

        response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('groupfield=1'), dedupField="__key__.groupfield", dedupSortField=["__numeric__.sort2","__numeric__.sort1"], core="main2", stop=10000)
        self.assertEqual(1, len(response.hits))
        self.assertEqual(1, response.total)
        self.assertEqual(100, response.totalWithDuplicates)
        self.assertEquals(['main2:record:199'], [hit.id for hit in response.hits]
        )
Esempio n. 9
0
 def testRemoteServiceOnBadPath(self):
     remote = SynchronousRemote(host='localhost',
                                port=self.httpPort,
                                path='/does/not/exist')
     self.assertRaises(IOError, lambda: remote.executeQuery(parseCql('*')))
Esempio n. 10
0
 def testRemoteService(self):
     remote = SynchronousRemote(host='localhost',
                                port=self.httpPort,
                                path='/remote')
     response = remote.executeQuery(parseCql('*'))
     self.assertEquals(100, response.total)
 def testRemoteServiceWithBadCore(self):
     remote = SynchronousRemote(host='localhost', port=self.httpPort, path='/remote')
     self.assertRaises(IOError, lambda: remote.executeQuery(cqlToExpression('*'), core='doesnotexist'))
 def testRemoteServiceOnBadPath(self):
     remote = SynchronousRemote(host='localhost', port=self.httpPort, path='/does/not/exist')
     self.assertRaises(IOError, lambda: remote.executeQuery(cqlToExpression('*')))
 def testRemoteService(self):
     remote = SynchronousRemote(host='localhost', port=self.httpPort, path='/remote')
     response = remote.executeQuery(cqlToExpression('*'))
     self.assertEquals(100, response.total)