Elasticsearch strange behaviour for queries straight after insertion

I am writing some integration tests for an app that uses Elasticsearch and
I am experiencing a strange behaviour. If I insert a document and I query
straight after that, I get different results every time. I suspect that,
albeit the insertion itself will return, the indexing itself doesn't take
place synchronously and, because of that, the query will experiment a race
condition with unpredictable results.

If this is the case: is there a way to synchronize, so that when I run my
queries, I know that they are ready and successful???

More details: I am using elasticsearch embedded and the query is a simple
filter. The only odd thing is that I am using 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 a thread Sleep to wait
some seconds).

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Dario,
The first thing that comes to mind: did you set the refresh parameter [1]
to true?

[1]

On Mon, Nov 4, 2013 at 6:58 PM, Dario Rossi darioros@gmail.com wrote:

I am writing some integration tests for an app that uses Elasticsearch and
I am experiencing a strange behaviour. If I insert a document and I query
straight after that, I get different results every time. I suspect that,
albeit the insertion itself will return, the indexing itself doesn't take
place synchronously and, because of that, the query will experiment a race
condition with unpredictable results.

If this is the case: is there a way to synchronize, so that when I run
my queries, I know that they are ready and successful???

More details: I am using elasticsearch embedded and the query is a simple
filter. The only odd thing is that I am using 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 a thread Sleep to wait
some seconds).

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Matteo Moci
http://it.linkedin.com/in/matteomoci

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.