ES 8.6.1 How to make the number result hits consistent when re-running the same query over and over

I have and index with 10 primaries and 10 replicas (number_of_replica is set to 1). Refresh interval is currently 5s.

There is a lot writing activity happenning on that index.

I have a query that queries for a specific time range in the past. I expect it to return 1000 hits always because the data is in the past.

Now, sometimes when I run the same query, the hits would fall below 1000. When I run the query again it would come back 1000.

From what I've researched, this seems to be an expected behaviour because every time the same query is run it maybe hitting different shards and if a refresh is happening the refresh might interfere with the results or something like that.

My question is, what is recommended to mitigate this so to get consistent results more frequently?

I tried using preference query parameter which by setting preference=foobar but doesn't seem to help.

Should I make refresh interval longer? Is there anything else that can be done?

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