# Modeling data relationships in ES and Kibana

**URL:** https://discuss.elastic.co/t/modeling-data-relationships-in-es-and-kibana/55904
**Category:** Kibana
**Created:** [July 19, 2016, 4:23pm UTC](https://discuss.elastic.co/t/modeling-data-relationships-in-es-and-kibana/55904 "2016-07-19T16:23:07Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![arthur-y](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arthur-y/32/7896_2.png) [@arthur-y](https://discuss.elastic.co/u/arthur-y)
#### Post date: [July 19, 2016, 4:23pm UTC](https://discuss.elastic.co/t/modeling-data-relationships-in-es-and-kibana/55904/1 "2016-07-19T16:23:07Z")

</div>

Hello all,  
I have a question about a data modeling in ElasticSearch to fulfill our use case.  
We have 2 instances of data - traffic and sale which can be matched by clickout\_id field. The relationship is one to many (one traffic clickout can cause multiple sales under same clickout\_id) as in this schematic example.  
Sometimes, traffic won't contain this "clickout\_id" field, sometimes it will and it's a unique value.

 ![](https://us1.discourse-cdn.com/elastic/original/2X/e/e930a10e296e649f9ba7630bb43b06ba95a3e169.png)

I was revising different approaches, described [here](https://www.elastic.co/guide/en/elasticsearch/guide/current/modeling-your-data.html), namely:

1. Nesting objects
2. Storing data in different \_types by providing different mappings within one index
3. Children-parent relationship

Storing data in different \_types, trying to emulate DBMS behaviour won't work, I asked this question [earlier](https://discuss.elastic.co/t/refering-to-a-specific--type-in-kibana/55632). If the field in mappings have the same name, Lucene will not handle it.

My issue is that applying nesting objects approach works fine in Elastic, but will not be working correctly in Kibana, as it does not recognize an array. Thus, I cannot build any visualizations.

**The questions are:**

1. Perhaps I did a mistake when uploaded nested documents and/or mappings for specific index (I can describe the process).
2. Maybe child-parent relationship will suit better, but I cannot see how can I apply this in Kibana
3. The aim is to query documents in Kibana and Timelion freely

I would appreciate any hints,  
Best

---

<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: [July 20, 2016, 6:52am UTC](https://discuss.elastic.co/t/modeling-data-relationships-in-es-and-kibana/55904/2 "2016-07-20T06:52:41Z")

</div>

Just store each event as a document with a transaction ID or similar.

---

<div class="post-metadata">

### Author: ![arthur-y](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arthur-y/32/7896_2.png) [@arthur-y](https://discuss.elastic.co/u/arthur-y)
#### Post date: [July 20, 2016, 8:00am UTC](https://discuss.elastic.co/t/modeling-data-relationships-in-es-and-kibana/55904/3 "2016-07-20T08:00:57Z")

</div>

That's what we doing right now  
But the main questions/possible solutions that are:

1. Store data in separate indexes unmerged
2. Merge data and store traffic data and sale merged data in separate indexes
3. Apply nested objects approach and store subset of sale data within traffic data as an array (does not work out in Kibana)

I know it is hard to recommend something, not being aware of a use case specifics.

---

<div class="post-metadata">

### Author: ![arthur-y](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arthur-y/32/7896_2.png) [@arthur-y](https://discuss.elastic.co/u/arthur-y)
#### Post date: [July 20, 2016, 8:59am UTC](https://discuss.elastic.co/t/modeling-data-relationships-in-es-and-kibana/55904/4 "2016-07-20T08:59:24Z")

</div>

@warkolm Correct me if I am wrong please, but does Kibana support arrays data?  
I saw an issue described here -[Github](https://github.com/elastic/kibana/issues/998) and also a workaround in one [discussion](https://discuss.elastic.co/t/dealing-with-array-data/32703) .  
As far as I understand, it can count the amount of objects in array, but cannot make other aggregations (sum, average, etc.) as in my example - [http://prnt.sc/butwkb](http://prnt.sc/butwkb), right?  
Here is the screenshot of how array is displayed in Discover section - [http://prntscr.com/bv5m5i](http://prntscr.com/bv5m5i)

---

<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 6, 2017, 1:45pm UTC](https://discuss.elastic.co/t/modeling-data-relationships-in-es-and-kibana/55904/5 "2017-07-06T13:45:36Z")

</div>


