I want to make JSON to get queries from elastic search. I'm usgin this code to build the query:
search_doc = {}
search_doc.update({"sort": [{"re_max": {"order": "desc"}}]})
search_doc.update({"from": 0})
search_doc.update({"size": 100})
search_doc.update({"filter": {"and": [{"term": {"country_id": "10"}},{"range": {"pub_date": {"gte": "2014-06-07T00:00:00.0", "lte": "2014-06-07T23:59:59.0"}}}]}})
as you see I've used double quotation in all my strings, but look at the printed result:
{'sort': [{'re_max': {'order': 'desc'}}], 'filter': {'and': [{'term': {'country_id': '10'}}, {'range': {'pub_date': {'gte': '2014-06-07T00:00:00.0', 'lte': '2014-06-07T23:59:59.0'}}}]}, 'from': 0, 'size': 100}
All with single quotation which is invalid in JSON format or at least Elastic search will not accept it. Is there a way to make my strings in a valid JSON format? I think this is not a good way to replace single quotations with double quotations. please help me if there is a way.