# Is it possible to perform an operation on fields from two different indexes?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-perform-an-operation-on-fields-from-two-different-indexes/191883>\
**Category:** Elasticsearch\
**Created:** [July 23, 2019, 5:47pm UTC](https://discuss.elastic.co/t/is-it-possible-to-perform-an-operation-on-fields-from-two-different-indexes/191883 "2019-07-23T17:47:19Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![EZprogramming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ezprogramming/32/57291_2.png) [@EZprogramming](https://discuss.elastic.co/u/EZprogramming)\
**Post date:** [July 23, 2019, 5:47pm UTC](https://discuss.elastic.co/t/is-it-possible-to-perform-an-operation-on-fields-from-two-different-indexes/191883/1 "2019-07-23T17:47:19Z")

</div>

These are my indexes:

_ **stage-api-athena-fruitcount:** _

- upload\_time
- [other fields]

_ **stage-cloudwatch:** _

- Timestamp
- [other fields]

I want to perform the following action. Is it possible to do this operation on two separate indexes using either Kibana or Elasticsearch?

_`Timestamp - upload_time`_

---

<div class="post-metadata">

**Author:** ![EZprogramming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ezprogramming/32/57291_2.png) [@EZprogramming](https://discuss.elastic.co/u/EZprogramming)\
**Post date:** [July 24, 2019, 6:47pm UTC](https://discuss.elastic.co/t/is-it-possible-to-perform-an-operation-on-fields-from-two-different-indexes/191883/2 "2019-07-24T18:47:50Z")

</div>

Bump

---

<div class="post-metadata">

**Author:** ![EZprogramming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ezprogramming/32/57291_2.png) [@EZprogramming](https://discuss.elastic.co/u/EZprogramming)\
**Post date:** [July 25, 2019, 6:25pm UTC](https://discuss.elastic.co/t/is-it-possible-to-perform-an-operation-on-fields-from-two-different-indexes/191883/3 "2019-07-25T18:25:19Z")

</div>

I am still looking for an answer.

---

<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:** [July 25, 2019, 7:06pm UTC](https://discuss.elastic.co/t/is-it-possible-to-perform-an-operation-on-fields-from-two-different-indexes/191883/4 "2019-07-25T19:06:31Z")

</div>

Elasticsearch does not support joins, which what you are suggesting seems to be.

---

<div class="post-metadata">

**Author:** ![EZprogramming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ezprogramming/32/57291_2.png) [@EZprogramming](https://discuss.elastic.co/u/EZprogramming)\
**Post date:** [July 25, 2019, 7:07pm UTC](https://discuss.elastic.co/t/is-it-possible-to-perform-an-operation-on-fields-from-two-different-indexes/191883/5 "2019-07-25T19:07:31Z")

</div>

What if the two fields were in the same index. Would subtract operation be possible?

---

<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:** [July 25, 2019, 7:08pm UTC](https://discuss.elastic.co/t/is-it-possible-to-perform-an-operation-on-fields-from-two-different-indexes/191883/6 "2019-07-25T19:08:14Z")

</div>

That is generally still a join, so not possible.

---

<div class="post-metadata">

**Author:** ![EZprogramming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ezprogramming/32/57291_2.png) [@EZprogramming](https://discuss.elastic.co/u/EZprogramming)\
**Post date:** [July 25, 2019, 7:09pm UTC](https://discuss.elastic.co/t/is-it-possible-to-perform-an-operation-on-fields-from-two-different-indexes/191883/7 "2019-07-25T19:09:29Z")

</div>

I see, but I read something about script fields before. Have you used them? Do you think it would be useful in this scenario?

---

<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:** [July 25, 2019, 7:10pm UTC](https://discuss.elastic.co/t/is-it-possible-to-perform-an-operation-on-fields-from-two-different-indexes/191883/8 "2019-07-25T19:10:48Z")

</div>

Scripts and scripted fields run in the context of a single document, so I do not see how it would help here. If you have a unique identifier that links these two entries, create a document with that as an ID and then update it so you get all data in a single document.

---

<div class="post-metadata">

**Author:** ![EZprogramming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ezprogramming/32/57291_2.png) [@EZprogramming](https://discuss.elastic.co/u/EZprogramming)\
**Post date:** [July 25, 2019, 7:13pm UTC](https://discuss.elastic.co/t/is-it-possible-to-perform-an-operation-on-fields-from-two-different-indexes/191883/9 "2019-07-25T19:13:21Z")

</div>

By identifier, do you mean fields that are the same in both indexes? The two indexes both have customer\_id and farm\_id which are the same.

---

<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:** [July 25, 2019, 7:16pm UTC](https://discuss.elastic.co/t/is-it-possible-to-perform-an-operation-on-fields-from-two-different-indexes/191883/10 "2019-07-25T19:16:46Z")

</div>

If that is what links them, then concatenate them and use that as a document id.

---

<div class="post-metadata">

**Author:** ![EZprogramming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ezprogramming/32/57291_2.png) [@EZprogramming](https://discuss.elastic.co/u/EZprogramming)\
**Post date:** [July 25, 2019, 7:25pm UTC](https://discuss.elastic.co/t/is-it-possible-to-perform-an-operation-on-fields-from-two-different-indexes/191883/11 "2019-07-25T19:25:39Z")

</div>

Thanks for your suggestion, I will look into this solution.

---

<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:** [August 22, 2019, 7:25pm UTC](https://discuss.elastic.co/t/is-it-possible-to-perform-an-operation-on-fields-from-two-different-indexes/191883/12 "2019-08-22T19:25:43Z")

</div>

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