Hello Abdon,
Here is what I tried in the mentioned sequence.
Query: GET /hostaddressindex/host/_mapping
Response:
{
"hostaddressindex": {
"mappings": {
"host": {
"_all": {
"enabled": false
},
"properties": {
"ipAddress": {
"type": "ip",
"fields": {
"raw": {
"type": "text"
}
}
},
"link": {
"type": "text",
"index": false
},
"timeInterval": {
"type": "integer",
"index": false
}
}
}
}
}
}
Query: POST /hostaddressindex/host/1
{
"ipAddress" : "192.168.1.1",
"link" : "192.168.1.1|3",
"timeInterval" : [1]
}
Response:
{
"_index": "hostaddressindex",
"_type": "host",
"_id": "1",
"_version": 4,
"result": "updated",
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"created": false
}
Query:GET /hostaddressindex/host/1
Response:
{
"_index": "hostaddressindex",
"_type": "host",
"_id": "1",
"_version": 4,
"found": true,
"_source": {
"ipAddress": "192.168.1.1",
"link": "192.168.1.1|3",
"timeInterval": [
1
]
}
}
Query:
GET _search
{
"aggs" : {
"ip_ranges" : {
"ip_range" : {
"field" : "ipAddress.raw",
"ranges" : [
{
"mask" : "192.168.0.0/16"
}
]
}
}
}
}
Response:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 10,
"successful": 5,
"failed": 5,
"failures": [
{
"shard": 0,
"index": "indexing",
"node": "qzkSbw6dTDugoLnF5mECKw",
"reason": {
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [ipAddress] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
}
}
]
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "hostaddressindex",
"_type": "host",
"_id": "1",
"_score": 1,
"_source": {
"ipAddress": "192.168.1.1",
"link": "192.168.1.1|3",
"timeInterval": [
1
]
}
}
]
},
"aggregations": {
"ip_ranges": {
"buckets": [
{
"key": "192.168.0.0/16",
"from": "192.168.0.0",
"to": "192.169.0.0",
"doc_count": 1
}
]
}
}
}