# How can I query Elasticsearch to join or correlate data between two indices that have different field names but contain the same values?

**URL:** <https://discuss.elastic.co/t/how-can-i-query-elasticsearch-to-join-or-correlate-data-between-two-indices-that-have-different-field-names-but-contain-the-same-values/362448>\
**Category:** Kibana\
**Tags:** elastic-stack-monitoring\
**Created:** [July 3, 2024, 9:55am UTC](https://discuss.elastic.co/t/how-can-i-query-elasticsearch-to-join-or-correlate-data-between-two-indices-that-have-different-field-names-but-contain-the-same-values/362448 "2024-07-03T09:55:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anguri\_sudhakar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anguri_sudhakar/32/50050_2.png) [@anguri\_sudhakar](https://discuss.elastic.co/u/anguri_sudhakar)\
**Post date:** [July 3, 2024, 9:55am UTC](https://discuss.elastic.co/t/how-can-i-query-elasticsearch-to-join-or-correlate-data-between-two-indices-that-have-different-field-names-but-contain-the-same-values/362448/1 "2024-07-03T09:55:34Z")

</div>

1.I have two indices, `index1` and `index2`, and they have different field names but the values in these fields are the same. For example:

- `index1` has a field named `name1` with values like "value1", "value2", etc.
- `index2` has a field named `name2` with values like "value1", "value2", etc.

How can I write a query in Elasticsearch to effectively join or correlate the data between these two indices based on the matching values in `name1` and `name2`?

Note: writing above queries is it possible to display in Kibana dashboard..?  
i mean shell we create dashboards based up the query..?

---

<div class="post-metadata">

**Author:** ![ashishtiwari1993](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashishtiwari1993/32/135241_2.png) [@ashishtiwari1993](https://discuss.elastic.co/u/ashishtiwari1993)\
**Post date:** [July 3, 2024, 6:16pm UTC](https://discuss.elastic.co/t/how-can-i-query-elasticsearch-to-join-or-correlate-data-between-two-indices-that-have-different-field-names-but-contain-the-same-values/362448/2 "2024-07-03T18:16:15Z")

</div>

Is this something you're looking for

```auto
POST index1/_doc
{
  "name1":["value1","value2"]
}

POST index2/_doc
{
  "name2":["value1","value2"]
}

GET index1,index2/_search
{
  "query": {
    "multi_match": {
      "query": "value1",
      "fields": ["name1","name2"]
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![anguri\_sudhakar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anguri_sudhakar/32/50050_2.png) [@anguri\_sudhakar](https://discuss.elastic.co/u/anguri_sudhakar)\
**Post date:** [July 4, 2024, 10:17am UTC](https://discuss.elastic.co/t/how-can-i-query-elasticsearch-to-join-or-correlate-data-between-two-indices-that-have-different-field-names-but-contain-the-same-values/362448/3 "2024-07-04T10:17:19Z")

</div>

Shall I integrate above query in dashboard table ,is there document avaaible ..?

I need to use above query fetch the results and shown in table view
