How can we modify the document's _id?


(Ivan Ji) #1

Hi all,

Assume I insert a new document with the desired value to be its _id, which
means I don't need to find the document first when I need to modify its
field.
But if the _id is designed by the document's property and the property
changes, can the _id support be changed without deleting or re-indexing?

BTW, if I use the one of the document's field as _id by setting :

"_id" : { "path": "book_id" }

inside the schema.

When I update one document's book_id field, does the document's _id change
at the same time?

Ideas?

Regards,

Ivan

--
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/461af89e-10a2-496c-9254-b0a14022459e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Binh Ly) #2

In your above example, the document's id (_id) is generated the first time
from the book_id value (assuming you don't specify the id part in the REST
call). After that, any updates to the book_id value will only change the
book_id, i.e., the document's id will not change. If you want to change the
document's id, the best way is to delete the document and then index it
back with a different id.

--
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/6f0f0030-d0fe-45c6-a5a2-1ef102d1808f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #3