Saurav Prakash
Saurav Prakash

Reputation: 1947

Elasticsearch multiple index request on same document id in bulk api

We are using elastic search 6.0 and using bulk indexing to index many documents in a single request using “index” action. In a single request we can have a scenario where there are multiple “index” requests on same document. Will ES fail the bulk request in such case OR it will process all of them in order?

Edit1: I use a script for indexing in bulk request where we are handling out of order updates. So as long as all “index” requests are getting processed, we don’t have any issue.

Upvotes: 1

Views: 1557

Answers (1)

Val
Val

Reputation: 217344

ES will not fail, but it is not necessarily clear which indexing operation will "win". It might be the last one but since all operations in the bulk batch might be spread over several ingest nodes, and not all of those nodes process the indexing operations at the same rate, it might not be clear which operation will be processed first and which will be processed last.

The only guarantee that you have is that in the response, you'll get the state of each operation in the same order as specified in the request batch.

If your index has only one primary shard, then the order in which you submit the operations will be the same order as the one those operations are processed, hence the last one wins, but if you have more than one primary shard on more than one node, then you can't really know.

A better question would be why do you submit several indexing operations per document knowing in advance that only one will win?

Upvotes: 3

Related Questions