# Agrregate Filter For each

**URL:** https://discuss.elastic.co/t/agrregate-filter-for-each/65474
**Category:** Logstash
**Created:** [November 9, 2016, 11:37am UTC](https://discuss.elastic.co/t/agrregate-filter-for-each/65474 "2016-11-09T11:37:12Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![AndrePires](https://avatars.discourse-cdn.com/v4/letter/a/d07c76/32.png) [@AndrePires](https://discuss.elastic.co/u/AndrePires)
#### Post date: [November 9, 2016, 11:37am UTC](https://discuss.elastic.co/t/agrregate-filter-for-each/65474/1 "2016-11-09T11:37:13Z")

</div>

So I have this code:

filter {  
aggregate {  
task\_id =\> "%{id}"  
code =\> "  
map['Author'] ||= []  
event.to\_hash.each do |key,value|   
map[key] = value unless map.has\_key?(key)  
map[key] \<\< value if map[key].is\_a?(Array)  
end  
"  
push\_previous\_map\_as\_event =\> true  
timeout =\> 5  
timeout\_tags =\> ['aggregated']  
}   
if "aggregated" not in [tags] {  
drop {}  
}  
}

But I want to see if value is already in array before merginf to array.

Can someone help me please?

thanks

---

<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 7, 2016, 11:37am UTC](https://discuss.elastic.co/t/agrregate-filter-for-each/65474/2 "2016-12-07T11:37:23Z")

</div>

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