# Not giving correct column from translate pluging

**URL:** <https://discuss.elastic.co/t/not-giving-correct-column-from-translate-pluging/201386>\
**Category:** Logstash\
**Created:** [September 27, 2019, 11:24am UTC](https://discuss.elastic.co/t/not-giving-correct-column-from-translate-pluging/201386 "2019-09-27T11:24:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![namali](https://avatars.discourse-cdn.com/v4/letter/n/a87d85/32.png) [@namali](https://discuss.elastic.co/u/namali)\
**Post date:** [September 27, 2019, 11:24am UTC](https://discuss.elastic.co/t/not-giving-correct-column-from-translate-pluging/201386/1 "2019-09-27T11:24:49Z")

</div>

two csv files are

hotel.csv  
hotelcode,hotelname,citycode

CountryCityLive.csv  
citycode,CityName,CountryRegionCode,CountryCode

taking all columns from hotel.csv and from CountryCityLive.csv only take CountryRegionCode.

translate {  
destination =\> "[@metadata][citycode]"  
dictionary\_path =\> "/home/namalie/elk/travco/data/CountryCityLive.csv"  
field =\> "citycode" }  
dissect { mapping =\> { "[@metadata][citycode]" =\> "%{CountryRegionCode}" }}

But in data transferred in index has cityname data for CountryRegionCode.

and also following code not working if I want index with CityName and CountryRegionCode both

translate {  
destination =\> "[@metadata][citycode]"  
dictionary\_path =\> "/home/namalie/elk/travco/data/CountryCityLive1.csv"  
field =\> "citycode" }  
dissect { mapping =\> { "[@metadata][citycode]" =\> "%{CityName};%{CountryRegionCode}" }}

---

<div class="post-metadata">

**Author:** ![gitreseteasy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gitreseteasy/32/54026_2.png) [@gitreseteasy](https://discuss.elastic.co/u/gitreseteasy)\
**Post date:** [September 27, 2019, 11:53am UTC](https://discuss.elastic.co/t/not-giving-correct-column-from-translate-pluging/201386/2 "2019-09-27T11:53:41Z")

</div>

If the logs are coming in line-by-line, and we can be sure of the number of values each time, we could probably also just use a dissect?

Eg:

```
input{...}
filter {
    dissect {
        mapping => {
            "message" => "%{citycode},%{CityName},%{CountryRegionCode},%{CountryCode}"
        }
    }
}

```

If you are definitely going to remove the other fields, and will never care about CountryRegionCode, we could also accumulate the useless fields:

```
input{...}
filter {
    dissect {
        mapping => {
            "message" => "%{useless},%{+useless},%{CountryRegionCode},%{+useless}"
        }
    }
    mutate {
        remove_field => ["useless"]
    }
}
```

---

<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:** [September 27, 2019, 2:26pm UTC](https://discuss.elastic.co/t/not-giving-correct-column-from-translate-pluging/201386/3 "2019-09-27T14:26:53Z")

</div>

> [@gitreseteasy](#):
>
> we could also accumulate the useless fields

You don't need to accumlate them, just don't name them.

```
"message" => "%{},%{},%{CountryRegionCode},%{}"

```

---

<div class="post-metadata">

**Author:** ![namali](https://avatars.discourse-cdn.com/v4/letter/n/a87d85/32.png) [@namali](https://discuss.elastic.co/u/namali)\
**Post date:** [September 28, 2019, 1:02pm UTC](https://discuss.elastic.co/t/not-giving-correct-column-from-translate-pluging/201386/4 "2019-09-28T13:02:04Z")

</div>

thanks, I'll try this.

---

<div class="post-metadata">

**Author:** ![namali](https://avatars.discourse-cdn.com/v4/letter/n/a87d85/32.png) [@namali](https://discuss.elastic.co/u/namali)\
**Post date:** [September 28, 2019, 1:03pm UTC](https://discuss.elastic.co/t/not-giving-correct-column-from-translate-pluging/201386/5 "2019-09-28T13:03:05Z")

</div>

Thanks for the support, I'll try this as well

---

<div class="post-metadata">

**Author:** ![namali](https://avatars.discourse-cdn.com/v4/letter/n/a87d85/32.png) [@namali](https://discuss.elastic.co/u/namali)\
**Post date:** [September 30, 2019, 8:29am UTC](https://discuss.elastic.co/t/not-giving-correct-column-from-translate-pluging/201386/6 "2019-09-30T08:29:57Z")

</div>

tried both but given solution didn't work  
1)  
translate {  
destination =\> "[@metadata][statecode]"  
dictionary\_path =\> "/home/namalie/elk/travco/data/CountryCityLive1.csv"  
field =\> "citycode" }  
dissect { mapping =\> { "[@metadata][statecode]" =\> "%{useless},%{+useless},%{CountryRegionCode},%{+useless}" }}

didn't get anything

1. 

translate {  
destination =\> "[@metadata][statecode]"  
dictionary\_path =\> "/home/namalie/elk/travco/data/CountryCityLive1.csv"  
field =\> "citycode" }  
dissect { mapping =\> { "message" =\> "%{},%{CityName},%{CountryRegionCode},%{}" }}

got fields as CityName and CountryRegionCode but the data are wrong from some other csv

1. 

translate {  
destination =\> "[@metadata][statecode]"  
dictionary\_path =\> "/home/namalie/elk/travco/data/CountryCityLive1.csv"  
field =\> "citycode" }  
dissect { mapping =\> { "[@metadata][statecode]" =\> "%{useless},%{CityName},%{CountryRegionCode},%{+useless}" }}

didn't get anything

---

<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:** [October 28, 2019, 8:30am UTC](https://discuss.elastic.co/t/not-giving-correct-column-from-translate-pluging/201386/7 "2019-10-28T08:30:27Z")

</div>

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