# How to Map IP type

**URL:** <https://discuss.elastic.co/t/how-to-map-ip-type/114357>\
**Category:** Elasticsearch\
**Created:** [January 6, 2018, 8:41am UTC](https://discuss.elastic.co/t/how-to-map-ip-type/114357 "2018-01-06T08:41:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![f26227279](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/f26227279/32/21296_2.png) [@f26227279](https://discuss.elastic.co/u/f26227279)\
**Post date:** [January 6, 2018, 8:41am UTC](https://discuss.elastic.co/t/how-to-map-ip-type/114357/1 "2018-01-06T08:41:03Z")

</div>

this is my IPV4\_DST\_ADDR field mapping:

```
"IPV4_DST_ADDR":{"type":"text","norms":false,"fields":{"keyword":{"type":"keyword","ignore_above":256}}}

```

I want to change the type from text to IP, how can I do?

thank you in advance!

---

<div class="post-metadata">

**Author:** ![luiz.santos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luiz.santos/32/24664_2.png) [@luiz.santos](https://discuss.elastic.co/u/luiz.santos)\
**Post date:** [January 9, 2018, 10:59am UTC](https://discuss.elastic.co/t/how-to-map-ip-type/114357/2 "2018-01-09T10:59:54Z")

</div>

Hi @f26227279,

You can use the `"type": "ip"`, please take a look in the following example [taken from docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/ip.html):

```
PUT my_index
{
  "mappings": {
    "my_type": {
      "properties": {
        "IPV4_DST_ADDR": {
          "type": "ip"
        }
      }
    }
  }
}

PUT my_index/my_type/1
{
  "IPV4_DST_ADDR": "192.168.1.1"
}

GET my_index/_search
{
  "query": {
    "term": {
      "IPV4_DST_ADDR": "192.168.0.0/16"
    }
  }
}

```

Hope it helps.

Cheers,  
LG

---

<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 6, 2018, 11:00am UTC](https://discuss.elastic.co/t/how-to-map-ip-type/114357/3 "2018-02-06T11:00:02Z")

</div>

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