What are the sequence of low-level operations that happens during the execution of _delete_by_query operation? On a high-level _delete_by_query operates as follows:
- Multiple search requests are sequentially executed in order to find all the matching documents to delete.
- Every time a batch of documents is found, a corresponding bulk request is executed to delete all these documents.
Basically, I wanted to understand the following things:
- Whether the search request is routed to primary shard or happens at the node where the request is received?
- Does the delete operation wait for all the matching documents to be found or immediately deletes the matched document?
- Whether the delete operation is routed to primary shard or happens at the node where the request is received?
- After the search operation is done how does delete operation know whether the version of the document it is trying to delete is the latest one?
- Also, let's say that if somehow delete operation figures out that the version has been incremented after search operation then why does it throw version conflict. Shouldn't it just try to delete the latest version of the document?