# Logstash link fileds in aggregate filter

**URL:** https://discuss.elastic.co/t/logstash-link-fileds-in-aggregate-filter/167272
**Category:** Logstash
**Created:** [February 6, 2019, 11:08am UTC](https://discuss.elastic.co/t/logstash-link-fileds-in-aggregate-filter/167272 "2019-02-06T11:08:49Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![fedwe](https://avatars.discourse-cdn.com/v4/letter/f/a88e4f/32.png) [@fedwe](https://discuss.elastic.co/u/fedwe)
#### Post date: [February 6, 2019, 11:08am UTC](https://discuss.elastic.co/t/logstash-link-fileds-in-aggregate-filter/167272/1 "2019-02-06T11:08:49Z")

</div>

I have 2 files one that contains the filed number for example 961123456  
and the other file cointains : country\_code 961 country name x

can i use the aggregate filter to link the 2 fields to the number filed when indexing

cause i want to substring the number and return the code of it and the country in the same data table

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [February 6, 2019, 2:00pm UTC](https://discuss.elastic.co/t/logstash-link-fileds-in-aggregate-filter/167272/2 "2019-02-06T14:00:31Z")

</div>

I would use a translate filter rather than aggregate. You will need to be able to extract the country code from the phone number. There is code that can do that [here](https://github.com/googlei18n/libphonenumber). (You cannot use that directly, obviously, but it shows you all the logic required.)

Then if you have a csv (or yml, or json) that contains codes and names, like this

252,Somalia  
961,Lebanon  
51,Peru

[translate](https://www.elastic.co/guide/en/logstash/current/plugins-filters-translate.html) will map it for you.

---

<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: [March 6, 2019, 2:00pm UTC](https://discuss.elastic.co/t/logstash-link-fileds-in-aggregate-filter/167272/3 "2019-03-06T14:00:34Z")

</div>

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