def test_or_filter1(self):
     exp = GreaterEqual("a", 2) | Less("b", 3)
     assert exp.build() == {
         "bool": {
             "should": [{
                 "range": {
                     "a": {
                         "gte": 2
                     }
                 }
             }, {
                 "range": {
                     "b": {
                         "lt": 3
                     }
                 }
             }]
         }
     }
Exemple #2
0
 def test_and_not_or_filter(self):
     exp = GreaterEqual("a", 2) & ~(Less("b", 3) | Equal("c", 4))
     assert exp.build() == {
         "bool": {
             "must": [
                 {"range": {"a": {"gte": 2}}},
                 {
                     "bool": {
                         "must_not": {
                             "bool": {
                                 "should": [
                                     {"range": {"b": {"lt": 3}}},
                                     {"term": {"c": 4}},
                                 ]
                             }
                         }
                     }
                 },
             ]
         }
     }