# Mutate - Split - datatype remains string

**URL:** <https://discuss.elastic.co/t/mutate-split-datatype-remains-string/207995>\
**Category:** Logstash\
**Created:** [November 15, 2019, 6:03am UTC](https://discuss.elastic.co/t/mutate-split-datatype-remains-string/207995 "2019-11-15T06:03:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![varshesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varshesh/32/57699_2.png) [@varshesh](https://discuss.elastic.co/u/varshesh)\
**Post date:** [November 15, 2019, 6:03am UTC](https://discuss.elastic.co/t/mutate-split-datatype-remains-string/207995/1 "2019-11-15T06:03:48Z")

</div>

Hi,

I have a field with comma separated city names. I have applied simple split as below.

filter {  
mutate { split =\> { "city" =\> ',' } }  
}

But, in index mapping, the data type displayed is string. Can someone guide on this please.

Thanks,

Varsh..

---

<div class="post-metadata">

**Author:** ![philippkahr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/philippkahr/32/100137_2.png) [@philippkahr](https://discuss.elastic.co/u/philippkahr)\
**Post date:** [November 15, 2019, 7:42am UTC](https://discuss.elastic.co/t/mutate-split-datatype-remains-string/207995/2 "2019-11-15T07:42:55Z")

</div>

Hi,

if you could post an example that would be helpful. The City is always a string, a string is just an char array.

What kind of output where you expecting?

---

<div class="post-metadata">

**Author:** ![varshesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varshesh/32/57699_2.png) [@varshesh](https://discuss.elastic.co/u/varshesh)\
**Post date:** [November 19, 2019, 1:16pm UTC](https://discuss.elastic.co/t/mutate-split-datatype-remains-string/207995/3 "2019-11-19T13:16:09Z")

</div>

Hi,

I think it was my mistake! The issue is solved. It is storing as array only.  
BTW, do you know how can I get a value from an array matching a key? I mean, I am storing some values in index, for which I have ids, say department id. I have a list/master of department, where the id-\>department name is available. I need to store the department name in the index along with department id.

I tried a few filters like, translate and a couple of others, nothing works man.. Kind of stuck up on this since a few hours now !!

Your help will be great !

Thanks,

Varsh..

---

<div class="post-metadata">

**Author:** ![philippkahr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/philippkahr/32/100137_2.png) [@philippkahr](https://discuss.elastic.co/u/philippkahr)\
**Post date:** [November 26, 2019, 4:52pm UTC](https://discuss.elastic.co/t/mutate-split-datatype-remains-string/207995/4 "2019-11-26T16:52:11Z")

</div>

You should be able to do that with the translate filter in logstash

[https://www.elastic.co/guide/en/logstash/current/plugins-filters-translate.html#plugins-filters-translate-dictionary](https://www.elastic.co/guide/en/logstash/current/plugins-filters-translate.html#plugins-filters-translate-dictionary)

Let's say you have the following key values.

```auto
103445: "Department 1"
10230: "Departement 2"

```

your translate should look like this

```auto
translate{
  field => "department_id"
  destination => "departement_name"
  dictionary_path => "departements.yml"
}

```

---

<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 24, 2019, 4:52pm UTC](https://discuss.elastic.co/t/mutate-split-datatype-remains-string/207995/5 "2019-12-24T16:52:26Z")

</div>

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