# Elasticsearch query to update one document using data from another document in the same es

**URL:** <https://discuss.elastic.co/t/elasticsearch-query-to-update-one-document-using-data-from-another-document-in-the-same-es/271540>\
**Category:** Elasticsearch\
**Created:** [April 28, 2021, 5:06pm UTC](https://discuss.elastic.co/t/elasticsearch-query-to-update-one-document-using-data-from-another-document-in-the-same-es/271540 "2021-04-28T17:06:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chamiduz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chamiduz/32/63020_2.png) [@chamiduz](https://discuss.elastic.co/u/chamiduz)\
**Post date:** [April 28, 2021, 5:06pm UTC](https://discuss.elastic.co/t/elasticsearch-query-to-update-one-document-using-data-from-another-document-in-the-same-es/271540/1 "2021-04-28T17:06:56Z")

</div>

Hi,

I have static data stored in elasticsearch. for example country name and country id

```auto
{
"id" : 250,
"name" : "Sri Lanka"
}

{
"id" : 260,
"name" : "India"
}

```

I am getting another set of attraction data from a web service that has a country id and saved in the same elasticsearch

```auto
[{
"countryId" : 250,
"cityid" : 253344,
"attractionName" : "sigiriya"
},
{
"countryId" : 260,
"cityid" : 444345,
"attractionName" : "some attraction"
}]

```

I need to update the attraction object with the country name without retrieving any data.

```auto
[{
"countryId" : 250,
"cityid" : 253344,
"attractionName" : "sigiriya",
"countryName" : "Sri Lanka"
},
{
"countryId" : 260,
"cityid" : 444345,
"attractionName" : "some attraction",
"countryName" : "India"
}]

```

---

<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:** [May 26, 2021, 5:07pm UTC](https://discuss.elastic.co/t/elasticsearch-query-to-update-one-document-using-data-from-another-document-in-the-same-es/271540/2 "2021-05-26T17:07:08Z")

</div>

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