Reputation:
I have to perform a bulk index operation in elasticsearch. The data looks like
[{'code': 12, 'name': 'ABC', 'designation': 'ceo'},
{'code': 13, 'name': 'AIB', 'designation': 'cfo'},
{'code': 14, 'name': 'AXB', 'designation': 'cto'}]
While indexing i want to explicitly provide code as the id. It is simple when performing single indexing operation. I am not sure as to how can it be done in bulk index operation.
Upvotes: 0
Views: 410
Reputation: 19263
For indexing the format is different for bulk. There need to be 2 lines per index request. First one for meta data like indexname , type name and ID and second one , actual data -
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{ "field1" : "value1" }
You can specify the id in the first field. You can read more on this here.
Upvotes: 1