in our system we get different responses and I speculate it caused by "Adaptive Replica Selection".
the two queries are different but they should fetch the same document .
The first query check if the document have been deleted and from the logs I see it's returning 0 results.
{"query":{"bool":{"must":[{"terms":{"id":[65164]}}],"filter":[{"range":{"updated_at":{"gte":0}}}]}}}
the second query check using the date, and it's returning 1 result.
{"query":{"bool":{"must":[{"terms":{"employee_id":[163872]}},{"range":{"date":{"lte":19389}}}]}}}
weirdly the second query still returning the deleted document, even though we only run it after the first one(Guard Query).
is it caused by the replica or it's something else ?
I am confused as the two queries filter on different fields (id vs employee_id and updated_at vs date). How are these related? What are the mappings for the fields used in the queries? What does the document you are retrieving look like?
both query the same index, and the data look like this
{
id: 65164 -> integer
employee_id: 163872 -> integer
updated_at: 321450402302 -> long
date: 19123 -> integer
}
Based on what I can find, delete operations should follow the same model as writing documents. Therefore, you shouldn't get a successful response when deleting until all in-sync replicas have acknowledged the delete. Elasticsearch should only search in-sync shards.
Something you might be running into is shard refresh delays, where one shard might've refreshed and removed the document from search, while the other shard might not have refreshed yet, and still have the document available for search. This thread goes into the topic a bit more.
You might want to try passing the refresh=truequery parameter on the delete request to see if that helps resolve what you're seeing.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.