# How can we modify the document's \_id?

**URL:** <https://discuss.elastic.co/t/how-can-we-modify-the-documents--id/15868>\
**Category:** Elasticsearch\
**Created:** [February 18, 2014, 6:57am UTC](https://discuss.elastic.co/t/how-can-we-modify-the-documents--id/15868 "2014-02-18T06:57:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan\_Ji](https://avatars.discourse-cdn.com/v4/letter/i/d78d45/32.png) [@Ivan\_Ji](https://discuss.elastic.co/u/Ivan_Ji)\
**Post date:** [February 18, 2014, 6:57am UTC](https://discuss.elastic.co/t/how-can-we-modify-the-documents--id/15868/1 "2014-02-18T06:57:43Z")

</div>

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](mailto: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](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](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@Binh\_Ly](https://discuss.elastic.co/u/Binh_Ly)\
**Post date:** [February 18, 2014, 7:46pm UTC](https://discuss.elastic.co/t/how-can-we-modify-the-documents--id/15868/2 "2014-02-18T19:46:18Z")

</div>

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](mailto: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](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](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:49am UTC](https://discuss.elastic.co/t/how-can-we-modify-the-documents--id/15868/3 "2017-07-06T01:49:18Z")

</div>


