# Translate filter for most accurate NUMBER

**URL:** https://discuss.elastic.co/t/translate-filter-for-most-accurate-number/67917
**Category:** Logstash
**Created:** [December 3, 2016, 5:31am UTC](https://discuss.elastic.co/t/translate-filter-for-most-accurate-number/67917 "2016-12-03T05:31:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Hans](https://avatars.discourse-cdn.com/v4/letter/h/e19b73/32.png) [@Hans](https://discuss.elastic.co/u/Hans)
#### Post date: [December 3, 2016, 5:31am UTC](https://discuss.elastic.co/t/translate-filter-for-most-accurate-number/67917/1 "2016-12-03T05:31:28Z")

</div>

Hi, I would like to use the translate filter to identify a match. So I have extracted the first 5 numbers and added this to different fields as per example below. Now I would like to lookup the value starting with the most accurate `NUMBER_5` to `NUMBER_1`; however once a match is found the lookup should stop and write the value to the field.  
Example for Number extraction:  
`Number = 27725883355 NUMBER_1 = 2 NUMBER_2 = 27 NUMBER_3 = 277 NUMBER_4 = 2772 NUMBER_5 = 27725`

Translate lookup file example:  
`“27”: “SA” “277”: “SA_M” “264”: “NA” “1” “US” ….`

Current attempt for the filter:  
`translate { field => "NUMBER_5" destination => "NUMBER_FINAL" dictionary_path => "/etc/DATA.yaml" } translate { field => "NUMBER_4" destination => "NUMBER_FINAL" dictionary_path => "/etc/DATA.yaml" } translate { field => "NUMBER_3" destination => "NUMBER_FINAL" dictionary_path => "/etc/DATA.yaml" } translate { field => "NUMBER_2" destination => "NUMBER_FINAL" dictionary_path => "/etc/DATA.yaml" } translate { field => "NUMBER_1" destination => "NUMBER_FINAL" dictionary_path => "/etc/DATA.yaml" }`  
With the attempt above the last lookup is returned, while the more accurate one is not returned. The example as follows:  
`“27”: “SA” “277”: “SA_M”`  
I would like to have the SA\_M returned rather than just SA. Any assistance in getting a solution for this would be greatly appreciated.

---

<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 31, 2016, 5:31am UTC](https://discuss.elastic.co/t/translate-filter-for-most-accurate-number/67917/2 "2016-12-31T05:31:29Z")

</div>

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