for day in data: query = {"query": { "range": { "day": { "gte":day, "lte":day, }}}} result = es.delete_by_query(index='content', doc_type='_doc', body=query) item = data[day] doc = {"day": day, "p0": item['p0'], "p1": item['p1'], "p2": item['p2'], "p3": item['p3'], "p4": item['p4'], "p5": item['p5'], "p6": item['p6'], "p7": item['p7'], "@timestamp": edate + 'T00:00:00.0Z'} es.index(index="content", doc_type="_doc", body=doc)
data = { "2020-07-13":{ "p0":7, "p1":0, "p2":0, "p3":40, "p4":7, "p5":0, "p6":7, "p7":0 }, "2020-07-14":{ "p0":6, "p1":0, "p2":0, "p3":43, "p4":4, "p5":0, "p6":2, "p7":0 } }