# Relationship in elasticsearch

**URL:** <https://discuss.elastic.co/t/relationship-in-elasticsearch/254358>\
**Category:** Elasticsearch\
**Created:** [November 5, 2020, 7:25am UTC](https://discuss.elastic.co/t/relationship-in-elasticsearch/254358 "2020-11-05T07:25:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Syed.Ubaid](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Syed.Ubaid](https://discuss.elastic.co/u/Syed.Ubaid)\
**Post date:** [November 5, 2020, 7:25am UTC](https://discuss.elastic.co/t/relationship-in-elasticsearch/254358/1 "2020-11-05T07:25:15Z")

</div>

I have two tables in mysql and i want to join both tables and extract data in elk stack. I have join both tables and create view and import in elk stack but the thing is that data is duplicate . Is that possible through mapping that i can link both tables in one index ? for example i have customer table in which fields are coming customer name,national identification number , customer\_id and second table is email in which customer\_Id is coming so can i map both table in elk stack and index both table table in one index.?

---

<div class="post-metadata">

**Author:** ![Syed.Ubaid](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Syed.Ubaid](https://discuss.elastic.co/u/Syed.Ubaid)\
**Post date:** [November 5, 2020, 7:30am UTC](https://discuss.elastic.co/t/relationship-in-elasticsearch/254358/2 "2020-11-05T07:30:05Z")

</div>

for example i have customer which have expired identification in the second table email in which customer id is coming with email body and subject. What i want to show in the visualisation that how many email send to that customer in which have expired identification i have join both the tables in mysql and import in elk stack duplication data is showing in elk stack. Any help please

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 9, 2020, 2:04am UTC](https://discuss.elastic.co/t/relationship-in-elasticsearch/254358/3 "2020-11-09T02:04:01Z")

</div>

There's quite a few existing threads on this topic, I'd encourage you to check some of them.

TLDR;

- merge both of your tables before indexing, creating a flattened structure
- use parent/child

---

<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 7, 2020, 2:04am UTC](https://discuss.elastic.co/t/relationship-in-elasticsearch/254358/4 "2020-12-07T02:04:03Z")

</div>

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