Closing an index whilst indexing documents

What would be the effects of closing an index whilst in the process of performing a bulk index? We have a scenario where we want to be able to close the index to make changes. I haven't been able to find any way to identify clearly whether the index is indexing documents and prevent the action if so, so was interested in what might happen.

Some of the documents will be rejected with exceptions indicating that the index is now closed.

You are essentially racing the "close this index" request against the "index this document" requests, and the outcome for each document depends on who wins this race. Documents within a bulk index request should be thought of as being handled independently by the cluster, so there's no sense in which a document being rejected implies that that all later documents are also rejected.

If you have replicas then there's a chance the document will be indexed on a primary shard but not on one of its replicas. This will mark the replica as stale and force a peer recovery when the index is reopened.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.