Indexing new document and check version

when I create new document and call prepareIndex it overwrites an existing
one (was created just a nanosecond before this using another thread). Is it
possible to use ES versions to control this behavior like when doing

Problem is, that when document exists I can receive its version prior to
update and check if I'm updating correct version of document - this is
working. But when document is not in ES - so get will return null and
version as -1, and this is returned to more threads simultaneously they all
call prepareIndex but of coure only last document is saved. I cant pass -1
as version number into prepareIndex method, it just thow Exception from ES.

Is there any way to check versions on indexing new documents?

Thanks in advance

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
To view this discussion on the web visit
For more options, visit