Ejemplo n.º 1
0
            'field_name1:value_name1 AND (field_name2:((value_name2) OR (value_name3)))',
            'default_operator': 'AND'
        }
    },
    'NESTED_FILTER': {}
}

# Test filters
print '[ElasticQuery] Testing: filters & queries'
query = Query.range('field_name1', gt=0, lte=100)[1]
test('Query.range', query, FILTERS['RANGE'])

query = Query.prefix(field_name1='value_name1')[1]
test('Query.prefix', query, FILTERS['PREFIX'])

query = Query.term(field_name1='value_name1')[1]
test('Query.term', query, FILTERS['TERM'])

query = Query.terms(field_name1=['value_name1', 'value_name2'])[1]
test('Query.terms', query, FILTERS['TERMS'])

query = Filter.missing('field_name1')[1]
test('Filter.missing', query, FILTERS['FILTER_MISSING'])
query = Query.missing('field_name1')[1]
test('Query.missing', query, FILTERS['QUERY_MISSING'])

query = Query.raw_string('QUERYSTRING')[1]
test('Query.raw_string', query, FILTERS['RAW_STRING'])

query = Query.string(field_name1='value_name1',
                     field_name2=['value_name2', 'value_name3'])[1]
Ejemplo n.º 2
0
 def test_missing_arg(self):
     with self.assertRaises(MissingArgError):
         Query.term(None)