and, push the data to the ES using below python api.
@app.route('/add', methods=['POST']) def insert_data():
#directory = '/home/user'
dir = os.getcwd()
os.chdir(dir)
i = 1
#This function will read all the json payload in the given dir and upload to ES.
for filename in os.listdir(dir):
if filename.endswith(".json"):
f = open(filename)
status_content = f.read()
# Send the data into es
result=(es.index(index='svc_index', ignore=400, doc_type='doc',
id=i, body=json.loads(status_content)))
i = i + 1
print("result")
return jsonify(result)
That is not a valid timestamp for Elasticsearch, it's just a number. You will want it to be something like Date field type | Elasticsearch Reference [7.12] | Elastic for Elasticsearch to be able to translate that into UTC and then sort on.
Agreed, its treating it as number, but still the latest file has greater timestamp 1616618301 than es result 1616618210.
If I use datetime in python to store the value in json, it give serializable error. I need to convert it to string first then in ES mapping which is not working through python script.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.