# How to integrate tables to one document

**URL:** <https://discuss.elastic.co/t/how-to-integrate-tables-to-one-document/237094>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [June 15, 2020, 8:53am UTC](https://discuss.elastic.co/t/how-to-integrate-tables-to-one-document/237094 "2020-06-15T08:53:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Naoki\_Kaneko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/naoki_kaneko/32/66155_2.png) [@Naoki\_Kaneko](https://discuss.elastic.co/u/Naoki_Kaneko)\
**Post date:** [June 15, 2020, 8:53am UTC](https://discuss.elastic.co/t/how-to-integrate-tables-to-one-document/237094/1 "2020-06-15T08:53:57Z")

</div>

I have three tables as RDS, each refers to products, categories and genres  
The relation is that a product has many genres and a category has many genres and foreign keys tie them up.

I want to make it possible to search them by product name, genres and categories.  
Could you show me the best practice to integrate them into documents.

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [June 17, 2020, 3:27pm UTC](https://discuss.elastic.co/t/how-to-integrate-tables-to-one-document/237094/2 "2020-06-17T15:27:26Z")

</div>

Our usual recommendation is to flatten your data. So flatten everything down to a single record that has the genre and category inlined...

```auto
{
  "product": "1",
  "genre": ["comedy", "romance"],
  "category" ["entertainment"]
},
{
  "product": "2",
  "genre": ["comedy"],
  "category" ["entertainment", "sports"]
}

```

---

<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:** [July 15, 2020, 3:27pm UTC](https://discuss.elastic.co/t/how-to-integrate-tables-to-one-document/237094/3 "2020-07-15T15:27:28Z")

</div>

Closed on July 15, 2020, 3:27pm UTC

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