问题
In my index, I have an IP field. The type of the field is "ip".
I want to search all IPs who starts with "192.168"
All my tentative have failed with the following message:
failed to parse ip [192.168], not a valid ip address
Is there a way of doing this or should I change the type of the field to "string"?
Thanks.
回答1:
You can use range query for example like:
GET my_index/_search
{
"query": {
"range": {
"ip_addr": {
"gte": "192.168.0.0",
"lt": "192.168.255.255"
}
}
}
}
来源:https://stackoverflow.com/questions/37057919/match-partial-ip-with-elasticsearch