# Logstash nested object aggregation is not working

**URL:** https://discuss.elastic.co/t/logstash-nested-object-aggregation-is-not-working/107619
**Category:** Logstash
**Created:** [November 14, 2017, 7:59pm UTC](https://discuss.elastic.co/t/logstash-nested-object-aggregation-is-not-working/107619 "2017-11-14T19:59:32Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Farah\_Alrabee](https://avatars.discourse-cdn.com/v4/letter/f/46a35a/32.png) [@Farah\_Alrabee](https://discuss.elastic.co/u/Farah_Alrabee)
#### Post date: [November 14, 2017, 7:59pm UTC](https://discuss.elastic.co/t/logstash-nested-object-aggregation-is-not-working/107619/1 "2017-11-14T19:59:32Z")

</div>

I have 3 tables : user, post, comment are joined with left join. I created a nested object (posts) for each user. I'm able to aggregate the posts object but i want also to aggregate the comments object inside each posts ,it gives me each comment in separated object while more than one comments are having the same post id, i want to combine all post comments in one array. This is my filter :

filter {  
mutate {  
rename =\> {  
"post\_id" =\> "[posts][post\_id]"  
"post\_user" =\> "[posts][post\_user]"

```
"comment_id" => "[posts][comments][comment_id]" 
"comment_post" => "[posts][comments][comment_post]" 
}
}

```

aggregate {  
task\_id =\> "%{user\_id}"  
code =\> "  
map['posts'] ||= []  
"  
push\_previous\_map\_as\_event =\> true  
}

aggregate {  
task\_id =\> "%{[posts][post\_id]}"  
code =\> "  
map['posts']['comments'] ||= []  
"  
push\_previous\_map\_as\_event =\> true  
}  
}  
This is the result :

{  
'user\_id' : 2,  
'name' : 'farah',  
'posts' :  
[  
{  
'post\_id' : 1,  
'post\_user' : 2,  
'comments':  
{  
'comment\_id' : 1,  
'comment\_post':1  
}  
},  
{  
'post\_id' : 1,  
'post\_user' : 2,  
'comments':  
{  
'comment\_id' : 2,  
'comment\_post':1  
}  
},  
'post\_id' : 3,  
'post\_user' : 2,  
}  
]  
}

---

<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: [December 12, 2017, 7:59pm UTC](https://discuss.elastic.co/t/logstash-nested-object-aggregation-is-not-working/107619/2 "2017-12-12T19:59:34Z")

</div>

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