# Alternative to nested fields in Kibana

**URL:** <https://discuss.elastic.co/t/alternative-to-nested-fields-in-kibana/90839>\
**Category:** Kibana\
**Created:** [June 26, 2017, 3:12pm UTC](https://discuss.elastic.co/t/alternative-to-nested-fields-in-kibana/90839 "2017-06-26T15:12:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![xavi23](https://avatars.discourse-cdn.com/v4/letter/x/db5fbb/32.png) [@xavi23](https://discuss.elastic.co/u/xavi23)\
**Post date:** [June 26, 2017, 3:12pm UTC](https://discuss.elastic.co/t/alternative-to-nested-fields-in-kibana/90839/1 "2017-06-26T15:12:53Z")

</div>

Hello everyone,

I find the best alternative to visualize nested type fields in Kibana.

Now I use this solution, but i want to know if exists another method to resolve this problem?

I define the index with one unique field named obx, because always is the same structure. When i insert the documents in this field, I add a prefix before 'obx' field.

The problem is that i have to load some documents to the same 'nhc' but different 'date'.

I create this index and documents:

put test  
{  
"mappings" : {  
"test" : {  
"properties" : {  
"nhc":{"type":"integer"},  
"date":{"type":"date"},  
"obx":{  
"properties" : {  
"descr":{"type":"text"},  
"value":{"type":"integer"}  
}  
}}  
}  
}  
}

put test/test/1  
{  
"nhc":12345,  
"date":"2017-05-02",  
"0":{"obx":{  
"descr":"weight",  
"value":45  
}  
},  
"1":{"obx":{  
"descr":"lenght",  
"value":185  
}  
}  
}

put test/test/2  
{  
"nhc":12345,  
"date":"2017-05-03",  
"0":{"obx":{  
"descr":"weight",  
"value":46  
}  
},  
"1":{"obx":{  
"descr":"lenght",  
"value":180  
}  
}  
}

How i can resolve this to load all information in the same document but not use a nested field?

Thanks.

---

<div class="post-metadata">

**Author:** ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)\
**Post date:** [June 26, 2017, 9:12pm UTC](https://discuss.elastic.co/t/alternative-to-nested-fields-in-kibana/90839/2 "2017-06-26T21:12:53Z")

</div>

It's always easiest to deal with a flat structure.

> because always is the same structure

Is there a reason you need that "obx" property then? If they shape is the same, why not just make it part of the document's schema?

---

<div class="post-metadata">

**Author:** ![xavi23](https://avatars.discourse-cdn.com/v4/letter/x/db5fbb/32.png) [@xavi23](https://discuss.elastic.co/u/xavi23)\
**Post date:** [June 27, 2017, 6:45am UTC](https://discuss.elastic.co/t/alternative-to-nested-fields-in-kibana/90839/3 "2017-06-27T06:45:17Z")

</div>

Hello Joe\_Fleming,

I don't understand how "make it part of the document SCHEMA"..

Thanks.

---

<div class="post-metadata">

**Author:** ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)\
**Post date:** [June 27, 2017, 4:39pm UTC](https://discuss.elastic.co/t/alternative-to-nested-fields-in-kibana/90839/4 "2017-06-27T16:39:09Z")

</div>

Sorry I wasn't clear. What I meant was, why not move those properties up to the root of the document object?

```auto
{
"nhc":12345,
"date":"2017-05-03",
"descr":"weight",
"value":46
}

```

Or, better, why not drop the whole description and value thing and just use `prop: value`?

```auto
{
"nhc":12345,
"date":"2017-05-03",
"weight": 46,
"length": 180
}

```

That's an easier object to work with all around.

---

<div class="post-metadata">

**Author:** ![xavi23](https://avatars.discourse-cdn.com/v4/letter/x/db5fbb/32.png) [@xavi23](https://discuss.elastic.co/u/xavi23)\
**Post date:** [June 27, 2017, 5:03pm UTC](https://discuss.elastic.co/t/alternative-to-nested-fields-in-kibana/90839/5 "2017-06-27T17:03:56Z")

</div>

I don't put this (1\*) because in the original data i have some records, depending of the date field. In the home system i have one record for nhc and date. I thik that the best practice to load this data is with nested field, but Kibana don't accept nested fields.

In the home system i have one nhc, some dates, some obx. I want to load all this data in the same document (json) but i can't use nested fields.

(1\*)

{  
"nhc":12345,  
"date":"2017-05-03",  
"weight": 46,  
"length": 180  
}

---

<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 25, 2017, 5:04pm UTC](https://discuss.elastic.co/t/alternative-to-nested-fields-in-kibana/90839/6 "2017-07-25T17:04:03Z")

</div>

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