# One index field update based on some condition on field of another index

**URL:** <https://discuss.elastic.co/t/one-index-field-update-based-on-some-condition-on-field-of-another-index/234702>\
**Category:** Elasticsearch\
**Created:** [May 28, 2020, 9:18am UTC](https://discuss.elastic.co/t/one-index-field-update-based-on-some-condition-on-field-of-another-index/234702 "2020-05-28T09:18:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sarvendras](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sarvendras/32/46287_2.png) [@sarvendras](https://discuss.elastic.co/u/sarvendras)\
**Post date:** [May 28, 2020, 9:18am UTC](https://discuss.elastic.co/t/one-index-field-update-based-on-some-condition-on-field-of-another-index/234702/1 "2020-05-28T09:18:29Z")

</div>

Hi Elastic Team,

I have two index with below fields.

Index1:  
index1 has 2 below fields.  
RRN Flag  
1 nofraud  
2 nofraud  
3 nofraud  
4 fraud

Index2:  
this has only 1 field

RRN  
1  
2  
3  
10  
15

Requirement: We need to update flag fields values of index1 from "nofraud" to "fraud" if for all RRN of index1 which have matching RRN values in index2.

Please suggest how to do.I understand elaticsearch is nosql hence we can not join 2 indexes.But is there any other alternate way to do this

Thanks  
Sarvendra

---

<div class="post-metadata">

**Author:** ![sarvendras](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sarvendras/32/46287_2.png) [@sarvendras](https://discuss.elastic.co/u/sarvendras)\
**Post date:** [May 29, 2020, 11:56am UTC](https://discuss.elastic.co/t/one-index-field-update-based-on-some-condition-on-field-of-another-index/234702/2 "2020-05-29T11:56:58Z")

</div>

@ Elastic Team ..Please suggest..

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 29, 2020, 1:13pm UTC](https://discuss.elastic.co/t/one-index-field-update-based-on-some-condition-on-field-of-another-index/234702/3 "2020-05-29T13:13:27Z")

</div>

If this is a one-off fix or update I would recommend using update by query. Either run one task per value or a single task with a script that sets the value correctly based on the data in the event.

---

<div class="post-metadata">

**Author:** ![sarvendras](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sarvendras/32/46287_2.png) [@sarvendras](https://discuss.elastic.co/u/sarvendras)\
**Post date:** [June 1, 2020, 6:19am UTC](https://discuss.elastic.co/t/one-index-field-update-based-on-some-condition-on-field-of-another-index/234702/4 "2020-06-01T06:19:19Z")

</div>

Thanks for reply..but how we can do using update by query... here data is on two different indexes .in update by query elastic documentation all the examples are given using update based on some condition within same index..

Can yopu please share any example how we can do this with update query with 2 indexs..

Thanks  
Sarvendra

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [June 1, 2020, 6:43am UTC](https://discuss.elastic.co/t/one-index-field-update-based-on-some-condition-on-field-of-another-index/234702/5 "2020-06-01T06:43:03Z")

</div>

You would need to specify the content of the reference index as parameters to your update by query as you correctly cannot do it from one index to another. You could run one update by query per RRN or put the mapping of a few values at a time in a scripted update. If you have a large number of values it may be easier to create an external reindexing script.

---

<div class="post-metadata">

**Author:** ![sarvendras](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sarvendras/32/46287_2.png) [@sarvendras](https://discuss.elastic.co/u/sarvendras)\
**Post date:** [June 1, 2020, 8:24pm UTC](https://discuss.elastic.co/t/one-index-field-update-based-on-some-condition-on-field-of-another-index/234702/6 "2020-06-01T20:24:38Z")

</div>

Thanks Christian.Can you please any example to get how to implement as you suggested.

---

<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:** [June 29, 2020, 8:24pm UTC](https://discuss.elastic.co/t/one-index-field-update-based-on-some-condition-on-field-of-another-index/234702/7 "2020-06-29T20:24:53Z")

</div>

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