Example #1
0
 def test_nested_and_filter(self):
     """
     It should be possible to add another multi-clause filter inside
     of an existing multi-clause filter and have them nest correctly.
     """
     query_builder = QueryBuilder()
     query_builder.and_filter(
         Exists('value')
     )
     and_filter = query_builder.find_filter(And)
     and_filter.and_filter(
         Exists('nested_value')
     )
     self.assertEquals(
         query_builder.to_query()['filter'],
         {
             "and": [
                 {"exists": {"field": "value"}},
                 {
                     "and": [
                         {"exists": {
                             "field": "nested_value"
                         }}
                     ]
                 }
             ]
         }
     )