使用弹性搜索6.2.4
我有一个简单的过滤器索引设置,有 2 个字段ip_address
和title
. ip_address
有类型ip
,title
有类型text
。
渗滤器映射
{
"my-percolator-index": {
"mappings": {
"_doc": {
"dynamic": "true",
"properties": {
"query": {
"type": "percolator"
},
"ip_address": {
"type": "ip"
},
"title": {
"type": "text"
}
}
}
}
}
}
向具有 CIDR 范围的索引添加了渗透查询
{
"_index": "my-percolator-index",
"_type": "_doc",
"_id": "123456789",
"_version": 1,
"found": true,
"_source": {
"query": {
"bool": {
"must": {
"simple_query_string": {
"query": "192.168.0.0/16",
"fields": [
"ip_address"
],
"default_operator": "AND"
}
}
}
}
}
}
_search
向索引发出请求
{
"url": "http://localhost:9200/my-percolator-index/_search",
"auth": [
"<username>",
"<password>"
],
"json": {
"size": 200,
"query": {
"percolate": {
"field": "query",
"documents": [
{
"body": {
"ip_address": "192.168.1.1",
"title": "This is a test title"
}
}
]
}
},
"highlight": {
"fields": {
"ip_address": {
"pre_tags": "<hl>",
"post_tags": "</hl>"
}
},
"fragment_size": 250
},
"timeout": "10s"
},
"timeout": 15,
"verify": false
}
得到一个命中原始渗透查询的结果。
{
"took": 162,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1.0,
"hits": [
{
"_index": "my-percolator-index",
"_type": "_doc",
"_id": "123456789",
"_score": 1.0,
"_source": {
"query": {
"bool": {
"must": {
"simple_query_string": {
"query": "192.168.0.0/16",
"fields": [
"ip_address"
],
"default_operator": "AND"
}
}
}
}
},
"fields": {
"_percolator_document_slot": [
0
]
}
}
]
}
}
但是,没有任何亮点回来。如果我使用title
属性对其进行测试并将其与文本匹配,则突出显示会回来。
用于突出显示的 ip 类型是否存在问题?