# Aggregation with double nested arrays

**URL:** <https://discuss.elastic.co/t/aggregation-with-double-nested-arrays/307976>\
**Category:** Kibana\
**Created:** [June 23, 2022, 9:36am UTC](https://discuss.elastic.co/t/aggregation-with-double-nested-arrays/307976 "2022-06-23T09:36:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mo-ezzat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mo-ezzat/32/107413_2.png) [@mo-ezzat](https://discuss.elastic.co/u/mo-ezzat)\
**Post date:** [June 23, 2022, 9:36am UTC](https://discuss.elastic.co/t/aggregation-with-double-nested-arrays/307976/1 "2022-06-23T09:36:15Z")

</div>

Hello,  
I'm pretty new to the aggregations but I believe this is a bit complicated  
I've the following set of data

> ```
> "grossWeight" : 6.43,
> "netWeight" : 6.89,
> "previouid" : "",
> "itemData" : [
> {
> "quantity" : 7,
> "itemCode" : "10007020",
> "specs" : [
> {
> "rate" : 14,
> "model" : "V001",
> "Type" : "T1"
> },
> {
> "rate" : 22,
> "model" : "V231",
> "Type" : "T2"
> },
> 
> ```

I've already managed to make agg using grossWeight, netWeight together, using visualize or console no problem  
what I want to do, is to add to the aggregations the **Type** that lies within **specs** which lies within **itemData**  
knowing that there might be more than one field inside **itemData** and more than one field inside **specs**

is that doable?

a side question, if I wrote a request using console and wanted to visualized it, is it possible?

thank you

---

<div class="post-metadata">

**Author:** ![majagrubic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/majagrubic/32/74459_2.png) [@majagrubic](https://discuss.elastic.co/u/majagrubic)\
**Post date:** [June 24, 2022, 12:06pm UTC](https://discuss.elastic.co/t/aggregation-with-double-nested-arrays/307976/2 "2022-06-24T12:06:01Z")

</div>

You should be able to use that field like any other; it should be shown as `itemData.specs.Type` in Viusalize.  
You cannot visualize requests from the console as such, but you can use Discover to view your search results.

---

<div class="post-metadata">

**Author:** ![mo-ezzat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mo-ezzat/32/107413_2.png) [@mo-ezzat](https://discuss.elastic.co/u/mo-ezzat)\
**Post date:** [June 24, 2022, 11:04pm UTC](https://discuss.elastic.co/t/aggregation-with-double-nested-arrays/307976/3 "2022-06-24T23:04:48Z")

</div>

Thank you for the response, I'm not sure if I'm doing it wrong but it isn't in the fields drop down list to start with  
and when I try to enter it manually, it says that it's not there and the update button stays grayed out

there are other arrays on the same level as itemData, and neither of them shows in the field list, unlike other fields like grossWeight, netWeight it's already there

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/7/77fc932451567de0cf19f020b9e5f08935f9b295.png)

---

<div class="post-metadata">

**Author:** ![majagrubic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/majagrubic/32/74459_2.png) [@majagrubic](https://discuss.elastic.co/u/majagrubic)\
**Post date:** [June 25, 2022, 1:52am UTC](https://discuss.elastic.co/t/aggregation-with-double-nested-arrays/307976/4 "2022-06-25T01:52:27Z")

</div>

Can you post your mapping? The `field` for terms aggregation needs to be [Keyword](https://www.elastic.co/guide/en/elasticsearch/reference/current/keyword.html), [Numeric](https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html), [`ip`](https://www.elastic.co/guide/en/elasticsearch/reference/current/ip.html), [`boolean`](https://www.elastic.co/guide/en/elasticsearch/reference/current/boolean.html), or [`binary`](https://www.elastic.co/guide/en/elasticsearch/reference/current/binary.html).

Is "Type" mapped as a keyword?

---

<div class="post-metadata">

**Author:** ![mo-ezzat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mo-ezzat/32/107413_2.png) [@mo-ezzat](https://discuss.elastic.co/u/mo-ezzat)\
**Post date:** [June 25, 2022, 12:46pm UTC](https://discuss.elastic.co/t/aggregation-with-double-nested-arrays/307976/5 "2022-06-25T12:46:47Z")

</div>

they are both itemData and specs of **"type" : "nested"**

but Type has the following

> "Type" : {  
> "type" : "text",  
> "fields" : {  
> "keyword" : {  
> "type" : "keyword",  
> "ignore\_above" : 256  
> }  
> }

---

<div class="post-metadata">

**Author:** ![majagrubic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/majagrubic/32/74459_2.png) [@majagrubic](https://discuss.elastic.co/u/majagrubic)\
**Post date:** [June 27, 2022, 6:54am UTC](https://discuss.elastic.co/t/aggregation-with-double-nested-arrays/307976/6 "2022-06-27T06:54:23Z")

</div>

Please note that Kibana does not support aggregation on `nested` objects. Here is our [tracking issue](https://github.com/elastic/kibana/issues/1084) for that, which you can follow for updates on this.

---

<div class="post-metadata">

**Author:** ![mo-ezzat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mo-ezzat/32/107413_2.png) [@mo-ezzat](https://discuss.elastic.co/u/mo-ezzat)\
**Post date:** [June 28, 2022, 7:24am UTC](https://discuss.elastic.co/t/aggregation-with-double-nested-arrays/307976/7 "2022-06-28T07:24:35Z")

</div>

I see, Thank you for the help  
last question, is there like a way around that? like can I explode the nested objects?

---

<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 26, 2022, 7:25am UTC](https://discuss.elastic.co/t/aggregation-with-double-nested-arrays/307976/8 "2022-07-26T07:25:23Z")

</div>

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