Delete by query after realtime GET

Hi, everyone.
I'm using elasticsearch 6.3.2. As stated in ES 6.3 documentation GET API is realtime unless realtime parameter is not passed with false value. It is also written that this realtime behavior is achieved by forcing refresh of the document and other not visible documents since last refresh.
Indeed calling get returns last version of document.
It is said in documentation that DELETE by query API makes multiple search queries to find documents for deletion and if document changes during delete operation then conflict will occur.
Therefore when I make get request document should be refreshed and the last version of document should be available for search and then if I'll try to delete this document using DELETE by query API it should be deleted successfully because search queries that delete operation uses should return last version of the document.
The actual situation is that making GET request and then DELETE by query request results in conflict response.

This behavior is replicated in my application test.
I create document, update it, assert that document has changed since update by making realtime GET call and then perform index cleanup using DELETE by query request which results in conflict response.

Can anyone explain this behavior? Thanks!

you are almost correct. We do maintain 2 different searchers internally. For _GET we refresh the internal reader which means the changes are not visible to the EXTERNAL reader that is used for searches and this is also used for delete by query. If you want to make the changes visible you should call _refresh explicitly.

1 Like

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