I can set mappings of index being created in curl command like this:
{
"mappings":{
"logs_june":{
"_timestamp":{
"enabled":"true"
},
"properties":{
"logdate":{
"type":"date",
"format":"dd/MM/yyy HH:mm:ss"
}
}
}
}
}
But I need to create that index with elasticsearch client in python and set mappings.. what is the way ? I tried somethings below but not work:
self.elastic_con = Elasticsearch([host], verify_certs=True)
self.elastic_con.indices.create(index="accesslog", ignore=400)
params = "{"mappings":{"logs_june":{"_timestamp": {"enabled": "true"},"properties":{"logdate":{"type":"date","format":"dd/MM/yyy HH:mm:ss"}}}}}"
self.elastic_con.indices.put_mapping(index="accesslog",body=params)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…