# Elasticsearch transcation update

**URL:** <https://discuss.elastic.co/t/elasticsearch-transcation-update/65668>\
**Category:** Elasticsearch\
**Created:** [November 10, 2016, 1:52pm UTC](https://discuss.elastic.co/t/elasticsearch-transcation-update/65668 "2016-11-10T13:52:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![banu](https://avatars.discourse-cdn.com/v4/letter/b/2acd7d/32.png) [@banu](https://discuss.elastic.co/u/banu)\
**Post date:** [November 10, 2016, 1:52pm UTC](https://discuss.elastic.co/t/elasticsearch-transcation-update/65668/1 "2016-11-10T13:52:33Z")

</div>

Planning to do a transaction update and commit as single document throughout the day. How ES segment will create in this behavior and how segment forced to be merged automatically? Kindly provide your suggestions.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [November 10, 2016, 3:21pm UTC](https://discuss.elastic.co/t/elasticsearch-transcation-update/65668/2 "2016-11-10T15:21:52Z")

</div>

Elasticsearch doesn't have any sort of transaction semantics like a relational database. Refreshing the index is asynchronous as well. You can update documents using the \_update API or just by sending an HTTP PUT to `/index/type/id`. But there is no way to update two thing atomically.

---

<div class="post-metadata">

**Author:** ![banu](https://avatars.discourse-cdn.com/v4/letter/b/2acd7d/32.png) [@banu](https://discuss.elastic.co/u/banu)\
**Post date:** [November 11, 2016, 5:37am UTC](https://discuss.elastic.co/t/elasticsearch-transcation-update/65668/3 "2016-11-11T05:37:02Z")

</div>

Can we try this solution in java using action\_get ?

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [November 11, 2016, 2:45pm UTC](https://discuss.elastic.co/t/elasticsearch-transcation-update/65668/4 "2016-11-11T14:45:43Z")

</div>

You can use the `_update` API to update a document by sending a script or some fields to merge. You can use GET and POST and [`version`](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#index-versioning) to do optimistic concurrency control style updates. The `_update` API does that internally.

These features are all exposed over the transport client as well as the HTTP API. Switching from one to the other doesn't change the guarantees that Elasticsearch offers.

---

<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:** [December 9, 2016, 2:45pm UTC](https://discuss.elastic.co/t/elasticsearch-transcation-update/65668/5 "2016-12-09T14:45:46Z")

</div>

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