# Compare 2 fields in different indexes in Kibana

**URL:** <https://discuss.elastic.co/t/compare-2-fields-in-different-indexes-in-kibana/347930>\
**Category:** Kibana\
**Created:** [November 24, 2023, 12:29pm UTC](https://discuss.elastic.co/t/compare-2-fields-in-different-indexes-in-kibana/347930 "2023-11-24T12:29:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonnyo](https://avatars.discourse-cdn.com/v4/letter/j/8c91f0/32.png) [@jonnyo](https://discuss.elastic.co/u/jonnyo)\
**Post date:** [November 24, 2023, 12:29pm UTC](https://discuss.elastic.co/t/compare-2-fields-in-different-indexes-in-kibana/347930/1 "2023-11-24T12:29:04Z")

</div>

Hi. I would like to create a report in Kibana that compares the value of 2 fields that exist in different indexes, and output a True or False if they do or do not match. E.g.

index1.fieldA, index2.fieldA, is\_match

I was looking to use a Runtime field for 'is\_match' with a script such as:

```auto
if (doc['index1.fieldA'].value == doc['index2.fieldA'].value)
{
    emit("True");
}
else
{
    emit("False");
}

```

But it doesn't seem to like the 2 different index prefixes. Is there a way I can accomplish this?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)\
**Post date:** [December 1, 2023, 9:26pm UTC](https://discuss.elastic.co/t/compare-2-fields-in-different-indexes-in-kibana/347930/2 "2023-12-01T21:26:47Z")

</div>

Unfortunately, this won't work because runtime fields work on the fields of a single document at at time.

> [@jonnyo](#):
>
> I would like to create a report in Kibana that compares the value of 2 fields that exist in different indexes, and output a True or False if they do or do not match.

I'm not sure I follow this premise, because indices have documents, and documents have fields. How would the script know which document in the 2nd index to compare fields with?

---

<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 29, 2023, 9:27pm UTC](https://discuss.elastic.co/t/compare-2-fields-in-different-indexes-in-kibana/347930/3 "2023-12-29T21:27:41Z")

</div>

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