I would like to update an elasticsearch query with python.
From a first query to a Db I get this example of query as a string which I transform in a json file through:
query = json.loads(string_query)
example of the query:
{'bool':
{'must': [
{'range': {'field': {'gte': lowerbound, 'lt': upperbound}}}
],
'must_not': [{'match_phrase': {'field': {'query': 'word'}}}]}}
What I would like to do is to add fields to the query as:
{'bool':
{'must': [
{'range': {'field': {'gte': lowerbound, 'lt': upperbound}}},
{'range': {'field-2': {'gte': lowerbound, 'lt': upperbound}}}
{'bool': {'should': {'bool': {'must':
[
{'range': {'field': {'gte': lowerbound, 'lt': upperbound}}},
{'range': {'field-2': {'gte': lowerbound, 'lt': upperbound}}}
]}}}},
],
'must_not': [{'match_phrase': {'field': {'query': 'word'}}}]}}
is it possible to exploit some libraries or it should be done by 'hand' by building a new json from the first one?