Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚠️ this PR requires a proper review. I'm not 100% sure it will not brake things. It will help to avoid having a `must` key outside of `bool` context. Example: Before a fix: ``` { "query": { ... }, "aggs": { "topics": { "filters": { "filters": { ... "bool": { "must": { "bool": { "must": [ { "query_string": { ... } } ] } } } } } } } } ``` which cause a ``` "caused_by": { "type": "named_object_not_found_exception", "reason": "[87:33] unknown field [must]" } ``` after the fix: ``` { "query": { ... }, "aggs": { "topics": { "filters": { "filters": { ... "query": { "bool": { "must": [ { "query_string": { ... } } ] } } } } } } } ``` Initial query provided to `fix_query`: ```{'query': {'bool': {'must_not': [{'term': {'type': 'composite'}}, {'constant_score': {'filter': {'exists': {'field': 'nextversion'}}}}], 'must': [{'term': {'_id': 'foo'}}], 'should': [], 'filter': [{'bool': {'must': [{'term': {'_type': 'items'}}]}}]}}, 'aggs': {'topics': {'filters': {'filters': {'created_to_old': {'bool': {'must': [{'range': {'versioncreated': {'lte': '2017-01-01T23:59:59+0000'}}}]}}, 'created_from_future': {'bool': {'must': [{'range': {'versioncreated': {'gte': '2020-09-17T04:00:00+0000'}}}]}}, 'filter': {'bool': {'must': [{'terms': {'genre.name': ['other']}}]}}, 'query': {'bool': {'must': [{'query_string': {'query': 'Foo', 'default_operator': 'AND', 'lenient': True}}]}}}}}}, 'size': 0}```
- Loading branch information