# Can you join indexes with different fields using an index pattern?

**URL:** https://discuss.elastic.co/t/can-you-join-indexes-with-different-fields-using-an-index-pattern/190599
**Category:** Elasticsearch
**Created:** [July 15, 2019, 6:45pm UTC](https://discuss.elastic.co/t/can-you-join-indexes-with-different-fields-using-an-index-pattern/190599 "2019-07-15T18:45:39Z")
**Posts on this page:** 5
**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 15, 2019, 6:45pm UTC](https://discuss.elastic.co/t/can-you-join-indexes-with-different-fields-using-an-index-pattern/190599/1 "2019-07-15T18:45:39Z")

</div>

**Problem:**

I have two indexes, stage-ath and stage-athena. I defined my index pattern as stage-ath\* to cover both index fields.

stage-ath has customer\_name + customer\_id  
stage-athena has only customer\_id and other fields which are not important in this example.

When creating a visualization table on stage-ath\* index pattern, I cannot see any value for customer\_name, it says "No Result Found".

**Questions:**

1. Is there any way to use index patterns to kind of join the information from both tables with one another?
2. Is there any change I need to make to my mapping for my two indexes?

**Mappings:**

_Stage-athena map:_

```
PUT /stage-athena/
PUT /stage-athena/_mapping
{
  "properties" : {
    "@timestamp" : {
      "type" : "date"
    },
    "@version" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "capture_time" : {
      "type" : "date"
    },
    "color" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "customer_id" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "direction" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "duration_hour" : {
      "type" : "long"
    },
    "farm_id" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "firmware_version" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "hardware_version" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "machine_id" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "phase_id" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "record_type" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "row_captured" : {
      "type" : "long"
    },
    "row_number" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "row_session_id" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "tomato_count" : {
      "type" : "long"
    },
    "type" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "upload_time" : {
      "type" : "date"
    },
    "uuid" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "version" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    }
  }  

```

_Stage-ath mapping:_

```
{
    "properties":{ 
        "customer_id":{
            "type" : "text",
            "fields" : {
                "keyword" : {
                    "type" : "keyword",
                    "ignore_above" : 256
                }
            }
        }, 
        "customer_name":{
            "type" : "text",
            "fields" : {
                "keyword" : {
                    "type" : "keyword",
                    "ignore_above" : 256
                }
            }
        }
    }
}

```

**Index pattern:**

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/e/4e0f47ea7c195c998a8fb86aa766ca129cb4141b.png)

**Kibana Visualization Result:**

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/4/d45811b42d5fffc56ea5042dabc5c7cf6a654e82.png)

Note: stage-ath\* index pattern includes fields from both stage-ath and stage-athena indexes in the above Kibana configurations.

---

<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 16, 2019, 8:41pm UTC](https://discuss.elastic.co/t/can-you-join-indexes-with-different-fields-using-an-index-pattern/190599/2 "2019-07-16T20:41:37Z")

</div>

Bump

---

<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 17, 2019, 4:10am UTC](https://discuss.elastic.co/t/can-you-join-indexes-with-different-fields-using-an-index-pattern/190599/3 "2019-07-17T04:10:03Z")

</div>

Elasticsearch does not support joins so I am not sure you can do what you want. I suspect you may show aggregations across fields from different types of documents, but if you filter on a field that only exists in one index that will not necessarily have the effect you want.

---

<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 17, 2019, 11:09pm UTC](https://discuss.elastic.co/t/can-you-join-indexes-with-different-fields-using-an-index-pattern/190599/4 "2019-07-17T23:09:30Z")

</div>

Thanks for your suggestion. The problem was I have two indexes, and I kept pushing Elasticsearch to act like a relational database to join/merge these two indexes using an index pattern that could cover both indexes. Well, Elasticsearch is a search engine, and to do what I wanted to do with it doesn't make sense.

Solution:

My data sources were coming from AWS Athena and a Backend API containing customer data. I wrote a Python script (which used data frames from pandas library) which would receive the missing information from both data sources and merge them on the same columns existing in both tables. After doing this, I ended up having a table cotaining the merged information from both Athena and my API, I then sent data to Elasticsearch for indexing and built my visualizations in Kibana with no problem.

Hope this helps others out.

---

<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 14, 2019, 11:09pm UTC](https://discuss.elastic.co/t/can-you-join-indexes-with-different-fields-using-an-index-pattern/190599/5 "2019-08-14T23:09:40Z")

</div>

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