# Aggregate fields based on nested filter with custom separator

**URL:** <https://discuss.elastic.co/t/aggregate-fields-based-on-nested-filter-with-custom-separator/98008>\
**Category:** Logstash\
**Created:** [August 23, 2017, 6:35am UTC](https://discuss.elastic.co/t/aggregate-fields-based-on-nested-filter-with-custom-separator/98008 "2017-08-23T06:35:20Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![malhotras](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@malhotras](https://discuss.elastic.co/u/malhotras)\
**Post date:** [August 25, 2017, 7:48am UTC](https://discuss.elastic.co/t/aggregate-fields-based-on-nested-filter-with-custom-separator/98008/15 "2017-08-25T07:48:36Z")

</div>

Yeah, i understand it. I understand that the duplicates are taken care of, I just wanted to confirm it. As, i did not make a test on my data to make sure it is working well.

Tested the script now. The confusion happend as I was printing the output as stdout (rubydebug). I think it is clear to me now.

I have some additional queries, more of ruby. If you could help here.

I want to modify the output such as digit to %02d and Year to last 2 digits only. So, here is how my string looks like now.

map['date'] += event.sprintf('%{group1}-%{group2}- **%02d%{under}-%{year}**')

I have to edit highlighted text here. under is single digit number want to print it as 02D and year is 4 digit want to print its last 2 digit only. Similarly i want to do uppercase and lowecase for some fields.

---

_[View the full topic](https://discuss.elastic.co/t/aggregate-fields-based-on-nested-filter-with-custom-separator/98008)._
