IPv4 datatype

An ip field is really a long field which accepts IPv4 addresses and indexes them as long values:

PUT my_index
{
  "mappings": {
    "my_type": {
      "properties": {
        "ip_addr": {
          "type": "ip"
        }
      }
    }
  }
}

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

GET my_index/_search
{
  "query": {
    "range": {
      "ip_addr": {
        "gte": "192.168.1.0",
        "lt":  "192.168.2.0"
      }
    }
  }
}

Parameters for ip fields

The following parameters are accepted by ip fields:

boost

Field-level index time boosting. Accepts a floating point number, defaults to 1.0.

doc_values

Should the field be stored on disk in a column-stride fashion, so that it can later be used for sorting, aggregations, or scripting? Accepts true (default) or false.

include_in_all

Whether or not the field value should be included in the _all field? Accepts true or false. Defaults to false if index is set to no, or if a parent object field sets include_in_all to false. Otherwise defaults to true.

index

Should the field be searchable? Accepts not_analyzed (default) and no.

null_value

Accepts an IPv4 value which is substituted for any explicit null values. Defaults to null, which means the field is treated as missing.

precision_step

Controls the number of extra terms that are indexed to make range queries faster. Defaults to 16.

store

Whether the field value should be stored and retrievable separately from the _source field. Accepts true or false (default).

IPv6 addresses are not supported yet.