I have an index with a handful of docs. These docs contain an array "subnets" who's individual elements of of type IP. They contain individual IPs as well as subnets.
Eg>
{
....,
....,
subnets: ["192.168.0.0/24", "224.0.0.0"]
....
I'm looking to run something similar to terms aggregation, where in my output contains a concatinated array of all the subnets that the query returns.
The below does not work because we can't run terms aggs on IP field. Is there any alertnative?
GET networks/_search
{
"query": {
"query_string": {
"query": "networkType: (org or Default)"
}
},
"_source": [
"subnets"
],
"aggs": {
"subnets": {
"terms": {
"field": "subnets"
}
}
}
}
Error:
root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Field [subnets] of type [ip_range] is not supported for aggregation [terms]"
}