Indexing new document and check version

Hi,
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
updates?

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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e651b694-ba6d-4a16-9c26-7d16008f164c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.