def test_combined_bool(self): tree = OrOp( AndOp(AndOp(ValueQuery(Value('aaa')), ValueQuery(Value('bbb'))), NotOp(ValueQuery(Value('ccc')))), ValueQuery(Value('ddd'))) ll = {"multi_match": {"fields": ["global_fulltext"], "query": "ddd"}} rr = { "bool": { "must": [{ "multi_match": { "fields": ["global_fulltext"], "query": "aaa" } }, { "multi_match": { "fields": ["global_fulltext"], "query": "bbb" } }] } } rl = { "bool": { "must_not": [{ "multi_match": { "fields": ["global_fulltext"], "query": "ccc" } }] } } r = {"bool": {"must": [rr, rl]}} d = {"bool": {"should": [r, ll]}} self.assertEqual(tree.accept(self.converter), d)
def test_combined_bool(self): tree = OrOp(AndOp(AndOp(ValueQuery(Value('aaa')), ValueQuery(Value('bbb'))), NotOp(ValueQuery(Value('ccc')))), ValueQuery(Value('ddd'))) ll = { "multi_match": { "fields": ["global_fulltext"], "query": "ddd" } } rr = { "bool": { "must": [ { "multi_match": { "fields": ["global_fulltext"], "query": "aaa" } }, { "multi_match": { "fields": ["global_fulltext"], "query": "bbb" } } ] } } rl = { "bool": { "must_not": [ { "multi_match": { "fields": ["global_fulltext"], "query": "ccc" } } ] } } r = { "bool": { "must": [rr, rl] } } d = { "bool": { "should": [r, ll] } } self.assertEqual(tree.accept(self.converter), d)
def test_or_query(self): tree = OrOp(KeywordOp(Keyword("boo"), Value("bar")), ValueQuery(Value("baz"))) self.assertEqual( tree.accept(self.converter), { "bool": { "should": [ {"multi_match": {"fields": ["boo"], "query": "bar"}}, {"multi_match": {"fields": ["_all"], "query": "baz"}}, ] } }, )
def test_combined_bool(self): tree = OrOp( AndOp(AndOp(ValueQuery(Value("aaa")), ValueQuery(Value("bbb"))), NotOp(ValueQuery(Value("ccc")))), ValueQuery(Value("ddd")), ) ll = {"multi_match": {"fields": ["_all"], "query": "ddd"}} rr = { "bool": { "must": [ {"multi_match": {"fields": ["_all"], "query": "aaa"}}, {"multi_match": {"fields": ["_all"], "query": "bbb"}}, ] } } rl = {"bool": {"must_not": [{"multi_match": {"fields": ["_all"], "query": "ccc"}}]}} r = {"bool": {"must": [rr, rl]}} d = {"bool": {"should": [r, ll]}} self.assertEqual(tree.accept(self.converter), d)
def test_or_query(self): tree = OrOp(KeywordOp(Keyword('boo'), Value('bar')), ValueQuery(Value('baz'))) self.assertEqual( tree.accept(self.converter), { "bool": { "should": [{ "multi_match": { "fields": ["boo"], "query": "bar", } }, { "multi_match": { "fields": ["global_fulltext"], "query": "baz", } }] } })
def test_or_query(self): tree = OrOp(KeywordOp(Keyword('boo'), Value('bar')), ValueQuery(Value('baz'))) self.assertEqual(tree.accept(self.converter), { "bool": { "should": [ { "multi_match": { "fields": ["boo"], "query": "bar", } }, { "multi_match": { "fields": ["global_fulltext"], "query": "baz", } } ] } })