在弹性搜索中具有类型Ip的字段上的通配符查询

问题描述 投票:0回答:1

我有一个索引模板,其字段类型为Ip,如下所示。

 "clientIpAddress": {
      "type": "ip"
  },

如何在这些字段上使用通配符搜索查询进行搜索。我正在尝试以下搜索查询。

"clientIpAddress":  "10.*"

但我收到错误:“'10。*'不是IP字符串文字。

需要帮助才能找到正确的通配符查询。

elasticsearch wildcard
1个回答
1
投票

您有两个选项来搜索IP类型的查询:

方法1:

curl -XPOST localhost:9200/index_name/type_name/_search -d '{
"query": {
"query_string": {
  "query": "clientIpAddress:[192.168.1.100 TO 192.168.1.102]"
}
}
}'

方法2:

curl -XPOST localhost:9200/index_name/type_name/_search -d '{
"query": {
"range": {
  "add": {
    "gte": "192.168.1.100",
    "lte": "192.168.1.102"
  }
}
}
}' 
© www.soinside.com 2019 - 2024. All rights reserved.