# Update data into elastic Search

**URL:** <https://discuss.elastic.co/t/update-data-into-elastic-search/121459>\
**Category:** Elasticsearch\
**Created:** [February 26, 2018, 9:34am UTC](https://discuss.elastic.co/t/update-data-into-elastic-search/121459 "2018-02-26T09:34:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sivaavish](https://avatars.discourse-cdn.com/v4/letter/s/b5a626/32.png) [@sivaavish](https://discuss.elastic.co/u/sivaavish)\
**Post date:** [February 26, 2018, 9:34am UTC](https://discuss.elastic.co/t/update-data-into-elastic-search/121459/1 "2018-02-26T09:34:25Z")

</div>

hi ,

i am new to elastic search . i imported data using log stash with MySQL. now i want update  
the some fields .  
here problem is after imported data through log stash id created automatically in elastic search.

UpdateRequest updateRequest=new UpdateRequest();  
updateRequest.index("indexName")  
.type("id")  
.id(id)  
.doc(jsonBuilder().startObject().field("fieldname","value").endObject());

 ![elasticSearch_img](https://us1.discourse-cdn.com/elastic/original/3X/3/5/35e5b41e515abf983f54b1b0d5b37a495d26c68b.png)

In Real Time how to know id for all the document.

Please share me how to update data into elastic search it should update into MySQL table also.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 26, 2018, 9:56pm UTC](https://discuss.elastic.co/t/update-data-into-elastic-search/121459/2 "2018-02-26T21:56:35Z")

</div>

You should define the id from your documents instead IMO.

So the id of your entity is the id of elasticsearch document.

---

<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:** [March 26, 2018, 9:56pm UTC](https://discuss.elastic.co/t/update-data-into-elastic-search/121459/3 "2018-03-26T21:56:36Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
