def test_consistency(self):
        uuid = str('10000')
        vb = 42
        seq = 101
        ixname = 'ix'

        mutinfo = (vb, uuid, seq, 'dummy-bucket-name')
        ms = MutationState()
        ms._add_scanvec(mutinfo)

        params = cbft.Params()
        params.consistent_with(ms)
        got = cbft.make_search_body('ix', cbft.MatchNoneQuery(), params)
        exp = {
            'indexName': ixname,
            'query': {
                'match_none': None
            },
            'ctl': {
                'consistency': {
                    'level': 'at_plus',
                    'vectors': {
                        ixname: {
                            '{0}/{1}'.format(vb, uuid): seq
                        }
                    }
                }
            }
        }
        self.assertEqual(exp, got)
    def test_consistency(self):
        uuid = str('10000')
        vb = 42
        seq = 101
        ixname = 'ix'

        mutinfo = (vb, uuid, seq, 'dummy-bucket-name')
        ms = MutationState()
        ms._add_scanvec(mutinfo)

        params = cbft.Params()
        params.consistent_with(ms)
        got = cbft.make_search_body('ix', cbft.MatchNoneQuery(), params)
        exp = {
            'indexName': ixname,
            'query': {
                'match_none': None
            },
            'ctl': {
                'consistency': {
                    'level': 'at_plus',
                    'vectors': {
                        ixname: {
                            '{0}/{1}'.format(vb, uuid): seq
                        }
                    }
                }
            }
        }
        self.assertEqual(exp, got)
 def test_string_query(self):
     exp_json = {
         'query': {
             'query': 'q*ry',
             'boost': 2.0,
         },
         'explain': True,
         'size': 10,
         'indexName': 'ix'
     }
     q = cbft.QueryStringQuery('q*ry', boost=2.0)
     p = cbft.Params(limit=10, explain=True)
     self.assertEqual(exp_json, cbft.make_search_body('ix', q, p))
Esempio n. 4
0
 def test_string_query(self):
     exp_json = {
         'query': {
             'query': 'q*ry',
             'boost': 2.0,
         },
         'explain': True,
         'size': 10,
         'indexName': 'ix'
     }
     q = cbft.StringQuery('q*ry', boost=2.0)
     p = cbft.Params(limit=10, explain=True)
     self.assertEqual(exp_json, cbft.make_search_body('ix', q, p))
Esempio n. 5
0
    def test_match_phrase(self):
        exp_json = {
            'query': {
                'match_phrase': 'salty beers',
                'analyzer': 'analyzer',
                'boost': 1.5,
                'field': 'field'
            },
            'size': 10,
            'indexName': 'ix'
        }

        p = cbft.Params(limit=10)
        q = cbft.MatchPhraseQuery('salty beers', boost=1.5, analyzer='analyzer',
                                  field='field')
        self.assertEqual(exp_json, cbft.make_search_body('ix', q, p))
Esempio n. 6
0
    def test_fuzzy(self):
        q = cbft.TermQuery('someterm', field='field', boost=1.5,
                           prefix_length=23, fuzziness=12)
        p = cbft.Params(explain=True)

        exp_json = {
            'query': {
                'term': 'someterm',
                'boost': 1.5,
                'fuzziness':  12,
                'prefix_length': 23,
                'field': 'field'
            },
            'indexName': 'someIndex',
            'explain': True
        }

        self.assertEqual(exp_json, cbft.make_search_body('someIndex', q, p))
Esempio n. 7
0
    def test_match_query(self):
        exp_json = {
            'query': {
                'match': 'salty beers',
                'analyzer': 'analyzer',
                'boost': 1.5,
                'field': 'field',
                'fuzziness': 1234,
                'prefix_length': 4
            },
            'size': 10,
            'indexName': 'ix'
        }

        q = cbft.MatchQuery('salty beers', boost=1.5, analyzer='analyzer',
                            field='field', fuzziness=1234, prefix_length=4)
        p = cbft.Params(limit=10)
        self.assertEqual(exp_json, cbft.make_search_body('ix', q, p))