# Elasticsearch one-to-many relations

**URL:** <https://discuss.elastic.co/t/elasticsearch-one-to-many-relations/163172>\
**Category:** Elasticsearch\
**Created:** [January 7, 2019, 9:18am UTC](https://discuss.elastic.co/t/elasticsearch-one-to-many-relations/163172 "2019-01-07T09:18:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ismailcakir](https://avatars.discourse-cdn.com/v4/letter/i/dbc845/32.png) [@ismailcakir](https://discuss.elastic.co/u/ismailcakir)\
**Post date:** [January 7, 2019, 9:18am UTC](https://discuss.elastic.co/t/elasticsearch-one-to-many-relations/163172/1 "2019-01-07T09:18:57Z")

</div>

Hi Everyone,

I have two table in SQL and i want to them to elasticsearch(thier relation is one to many).

Object1:  
{  
id,  
name,  
alias,  
...  
}

Object2:  
{  
id,  
idObject1,  
flag,  
....  
}

I am indexing this relation to elasticsearch like  
{  
elasticIndex:{  
id,  
name,  
alias,  
objects:[  
{  
id,  
idObject1,  
flag,  
....  
},  
{  
id,  
idObject1,  
flag,  
....  
},  
]  
}  
}

Is it possible to return only some of the objects items(maybe there is a 5 record but i want to return 2 record) without id,name,alias,... columns.

Should i create 2 index then join them or 1 index?

Thanks for your helps.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 7, 2019, 9:32am UTC](https://discuss.elastic.co/t/elasticsearch-one-to-many-relations/163172/2 "2019-01-07T09:32:02Z")

</div>

You should denormalize your data and index objects/items one by one of this is what you are searching for.

---

<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:** [February 4, 2019, 9:32am UTC](https://discuss.elastic.co/t/elasticsearch-one-to-many-relations/163172/3 "2019-02-04T09:32:03Z")

</div>

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