# How to index the ip address of long type

**URL:** <https://discuss.elastic.co/t/how-to-index-the-ip-address-of-long-type/43903>\
**Category:** Elasticsearch\
**Created:** [March 9, 2016, 2:13pm UTC](https://discuss.elastic.co/t/how-to-index-the-ip-address-of-long-type/43903 "2016-03-09T14:13:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lizhenmxcz](https://avatars.discourse-cdn.com/v4/letter/l/a88e57/32.png) [@lizhenmxcz](https://discuss.elastic.co/u/lizhenmxcz)\
**Post date:** [March 9, 2016, 2:13pm UTC](https://discuss.elastic.co/t/how-to-index-the-ip-address-of-long-type/43903/1 "2016-03-09T14:13:59Z")

</div>

hi, I want to index the data that has a ip address field stored as long. when i index the data with a ip type mapping, it says "mapper\_parsing\_exception", when i index it with a long type mapping, it cannot be query with ip. How can i deal with it and i can query with ip address

---

<div class="post-metadata">

**Author:** ![rusty](https://avatars.discourse-cdn.com/v4/letter/r/f17d59/32.png) [@rusty](https://discuss.elastic.co/u/rusty)\
**Post date:** [March 9, 2016, 4:02pm UTC](https://discuss.elastic.co/t/how-to-index-the-ip-address-of-long-type/43903/2 "2016-03-09T16:02:31Z")

</div>

Hi, you need to convert long to ip-address proir indexing if you want to use ip type.

---

<div class="post-metadata">

**Author:** ![lizhenmxcz](https://avatars.discourse-cdn.com/v4/letter/l/a88e57/32.png) [@lizhenmxcz](https://discuss.elastic.co/u/lizhenmxcz)\
**Post date:** [March 10, 2016, 2:05am UTC](https://discuss.elastic.co/t/how-to-index-the-ip-address-of-long-type/43903/3 "2016-03-10T02:05:39Z")

</div>

Thanks to @rusty. Why it cannot be converted automatically? This is inconvenient.

---

<div class="post-metadata">

**Author:** ![rusty](https://avatars.discourse-cdn.com/v4/letter/r/f17d59/32.png) [@rusty](https://discuss.elastic.co/u/rusty)\
**Post date:** [March 10, 2016, 7:20am UTC](https://discuss.elastic.co/t/how-to-index-the-ip-address-of-long-type/43903/4 "2016-03-10T07:20:51Z")

</div>

You can create a feature request on github to extend ip-type mapper with ability to use long value as ip address.  
Another way is scripting someting like [this solution](https://stackoverflow.com/questions/31908055/elasticsearch-how-to-convert-ip-long-to-string-to-get-ip-subnets-aggs).

---

<div class="post-metadata">

**Author:** ![lizhenmxcz](https://avatars.discourse-cdn.com/v4/letter/l/a88e57/32.png) [@lizhenmxcz](https://discuss.elastic.co/u/lizhenmxcz)\
**Post date:** [March 10, 2016, 1:57pm UTC](https://discuss.elastic.co/t/how-to-index-the-ip-address-of-long-type/43903/5 "2016-03-10T13:57:04Z")

</div>

@rusty thanks a lot. I am very intersted in elasticsearch community, but now i don't know how to create a feature request on github. I willl try my best to learn it and make contribution to the community.

---

<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:** [July 5, 2017, 11:09pm UTC](https://discuss.elastic.co/t/how-to-index-the-ip-address-of-long-type/43903/6 "2017-07-05T23:09:29Z")

</div>


