Data type long error

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.

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.

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?

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)

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