# Data type long error

**URL:** <https://discuss.elastic.co/t/data-type-long-error/272631>\
**Category:** Elasticsearch\
**Created:** [May 11, 2021, 3:59am UTC](https://discuss.elastic.co/t/data-type-long-error/272631 "2021-05-11T03:59:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nameisnotimportant](https://avatars.discourse-cdn.com/v4/letter/n/ea5d25/32.png) [@nameisnotimportant](https://discuss.elastic.co/u/nameisnotimportant)\
**Post date:** [May 11, 2021, 3:59am UTC](https://discuss.elastic.co/t/data-type-long-error/272631/1 "2021-05-11T03:59:43Z")

</div>

Hi,

ELK version: 7.10.0

I have a request, which is to import the ip2location csv data into elasticsearch and then use program (c# or python) to search the ip range and return the country info.

The data were not able to insert into elasticsearch. Log file message as below:

> Caused by: com.fasterxml.jackson.core.exc.InputCoercionException: Numeric value ( **58569106742025117821744233942091825152** ) out of range of long (-9223372036854775808 - 9223372036854775807)

So, i remove the conversion and let it be text and there is no issue with the insert process.

However, when it comes to searching, i can't search between the ip range. Below is the data range i am testing on.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/1/219b1cf61efb7e1d3ff8a78fa8c5cda0b7e4e1cb.png)

The following query does return one hit which is correct.

> ```
> GET /ip2location_2021_05_10/_search
> {
> "query": {
> "bool": {
> "must": [
> {"range": { "lower_ip_range": {"lte": "281470681743" }}},
> {"range": { "upper_ip_range": {"gte": "281470681743" }}}
> ]
> }
> }
> }
> 
> ```

The following query does not return any result (i remove the first character '2').

> ```
> GET /ip2location_2021_05_10/_search
> {
> "query": {
> "bool": {
> "must": [
> {"range": { "lower_ip_range": {"lte": "81470681743" }}},
> {"range": { "upper_ip_range": {"gte": "81470681743" }}}
> ]
> }
> }
> }
> 
> ```

Seems like inserting the data with text data type is not able to do range query.  
May i know how should i deal with this ?

Regard.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 11, 2021, 4:03am UTC](https://discuss.elastic.co/t/data-type-long-error/272631/2 "2021-05-11T04:03:35Z")

</div>

> [@nameisnotimportant](#):
>
> Seems like inserting the data with text data type is not able to do range query.

No, because text is not a numeric range that can be calculated against.

I'm a little lost with your IP formatting, why not use the IP type?

---

<div class="post-metadata">

**Author:** ![nameisnotimportant](https://avatars.discourse-cdn.com/v4/letter/n/ea5d25/32.png) [@nameisnotimportant](https://discuss.elastic.co/u/nameisnotimportant)\
**Post date:** [May 11, 2021, 4:22am UTC](https://discuss.elastic.co/t/data-type-long-error/272631/3 "2021-05-11T04:22:53Z")

</div>

> [@nameisnotimportant](#):
>
> ip2location csv

Thanks for your reply.

I am not using IP type because the data source is in IP number ([Convert IP2Location CSV data into IP ranges or CIDR | IP2Location.com](https://blog.ip2location.com/knowledge-base/convert-ip2location-csv-data-into-ip-ranges-or-cidr/))

---

<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:** [June 8, 2021, 4:23am UTC](https://discuss.elastic.co/t/data-type-long-error/272631/4 "2021-06-08T04:23:45Z")

</div>

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