# Can't convert the string datatype to ip

**URL:** <https://discuss.elastic.co/t/cant-convert-the-string-datatype-to-ip/115323>\
**Category:** Logstash\
**Created:** [January 12, 2018, 3:20pm UTC](https://discuss.elastic.co/t/cant-convert-the-string-datatype-to-ip/115323 "2018-01-12T15:20:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MartyA](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@MartyA](https://discuss.elastic.co/u/MartyA)\
**Post date:** [January 12, 2018, 3:20pm UTC](https://discuss.elastic.co/t/cant-convert-the-string-datatype-to-ip/115323/1 "2018-01-12T15:20:47Z")

</div>

mutate {  
convert =\> { "ip\_addr" =\> "ip" }  
}

I tried using this. It gives me an error before it even starts indexing anything. I read something in a post from about 2 years ago and it said convert can't change specialised datatypes. Is there another way to change the datatype of a string to ip?

---

<div class="post-metadata">

**Author:** ![paz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paz/32/28003_2.png) [@paz](https://discuss.elastic.co/u/paz)\
**Post date:** [January 12, 2018, 3:30pm UTC](https://discuss.elastic.co/t/cant-convert-the-string-datatype-to-ip/115323/2 "2018-01-12T15:30:23Z")

</div>

Mapping to IP doesn't happen inside Logstash, but rather in ElasticSearch.

You'd need to have a mapping or template applied to ElasticSearch where you define that specific field as IP, which then converts string values to IP datatypes internally.

---

<div class="post-metadata">

**Author:** ![MartyA](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@MartyA](https://discuss.elastic.co/u/MartyA)\
**Post date:** [January 12, 2018, 5:38pm UTC](https://discuss.elastic.co/t/cant-convert-the-string-datatype-to-ip/115323/3 "2018-01-12T17:38:37Z")

</div>

Thank you. That worked.

---

<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:** [February 9, 2018, 5:38pm UTC](https://discuss.elastic.co/t/cant-convert-the-string-datatype-to-ip/115323/4 "2018-02-09T17:38:59Z")

</div>

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