I am writing some integration tests for an application using Elasticsearch, and I am experiencing strange behavior. If I insert a document and immediately ask, I get different results every time. I suspect that although the insert itself will return, the indexing itself does not occur synchronously, and because of this, the query will experiment with the race condition with unpredictable results.
If so: is there a way to synchronize, so when I run my queries, I know that they are ready and successful.
More: I use elasticsearch embedded, and the query is a simple filter. The only strange thing is that I use template files for the document model.
EDIT: I even tried to get the document by ID after insertion, but the queries still return random results (unless I put the "Dream" thread for a few seconds).
source share