Saving "newest" document

If I have a document, that's being saved with a key, and a document already
exists with that same key, is there any way to only save "newest" document?
For example, if I have a key abc, and a date 2013-08-10 and a document
comes in with key abc and an older date, any way to let es know and ignore
the update, since the document is older? And if a newer document comes in,
then overwrite abc with newer document. I am concerned that if I pull the
value to compare in the code, then in a multi-threaded environment, I could
still lose the latest doc. Not to say that same can't happen within ES, but
just curious if I set _version field or something to time stamp, would that
do anything or any way to force saving only latest?

Thanks
Victor

--
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.

See versioning in http://www.elasticsearch.org/guide/reference/api/index_/

I think that setting version_type to external could help here. Send date in ms as version number.
You should get failures in case of indexing with an older value.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 3 août 2013 à 20:04, Victor D vmv890@gmail.com a écrit :

If I have a document, that's being saved with a key, and a document already exists with that same key, is there any way to only save "newest" document?
For example, if I have a key abc, and a date 2013-08-10 and a document comes in with key abc and an older date, any way to let es know and ignore the update, since the document is older? And if a newer document comes in, then overwrite abc with newer document. I am concerned that if I pull the value to compare in the code, then in a multi-threaded environment, I could still lose the latest doc. Not to say that same can't happen within ES, but just curious if I set _version field or something to time stamp, would that do anything or any way to force saving only latest?

Thanks
Victor

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.

--
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.