codeBarer
codeBarer

Reputation: 2388

Elasticsearch filtering by specific token

I'm new to elasticsearch and I'm trying to use it for my web development college project. Is it possible to aggregate the data below by a specific subset of the IP address?

{
    {
        "ip": "192.168.0.1",
        "host": "Gateway"
    },
    {
        "ip": "192.168.2.3",
        "host": "A"
    },
    {
        "ip": "192.168.2.4",
        "host": "B"
    }
}

I want to be able to aggregate totals based ip address subset of xxx.xxx.2.* so the total value should return 2, (host: A and B)

Thanks in advance!

Upvotes: 0

Views: 85

Answers (1)

Stanislav
Stanislav

Reputation: 596

You can use Wildcard Query if you want to get total value only. Like:

post ipaddress\data\_search
{
    "query":{
        "bool" : {
            "must" : {
                "wildcard" : { "ip" : "*.*.2.*" }
            }
        }    
    }
}

Upvotes: 1

Related Questions