I have to store some message in ElasticSearch integrate with my python program. Now what I try to store the message is:
d={\"message\":\"this is message\"}
There are two options which I can think of at the moment:
1. Define index name and document type with each entity:
es_client = Elasticsearch()
body = []
for entry in entries:
body.append({'index': {'_index': index, '_type': 'doc', '_id': entry['id']}})
body.append(entry)
response = es_client.bulk(body=body)
2. Provide the default index and document type with the method:
es_client = Elasticsearch()
body = []
for entry in entries:
body.append({'index': {'_id': entry['id']}})
body.append(entry)
response = es_client.bulk(index='my_index', doc_type='doc', body=body)
Works with:
ES version:6.4.0
ES python lib: 6.3.1