The requested URL was not found on this server. 不管你信不信,反正我是没找到

elasticsearch pinyin 搜索中文无法高亮

Elasticsearch | 作者 Y_H | 发布于2020年01月07日 | 阅读数:1309

索引:
{
"test" : {
"aliases" : { },
"mappings" : {
"properties" : {
"content" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "standard"
},
"create_time" : {
"type" : "date",
"format" : "yyy-MM-dd HH:mm:ss"
},
"name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
},
"pinyin" : {
"type" : "text",
"analyzer" : "pinyin_full_analyzer"
}
},
"analyzer" : "standard"
}
}
},
"settings" : {
"index" : {
"analysis" : {
"filter" : {
"pinyin_full_filter" : {
"term_vector" : "with_positions_offsets",
"keep_joined_full_pinyin" : "true",
"lowercase" : "true",
"type" : "pinyin",
"keep_original" : "true",
"keep_full_pinyin" : "true"
}
},
"analyzer" : {
"pinyin_full_analyzer" : {
"filter" : [
"asciifolding",
"lowercase",
"pinyin_full_filter"
],
"type" : "pinyin",
"tokenizer" : "standard"
}
}
},
"number_of_replicas" : "1",
"uuid" : "nLugUUfdSmGZzhlmjJgCIg",
"version" : {
"created" : "7040099"
}
}
}
}
}

插入数据后,搜索的结果中文无法高亮
GET test/_search
{
"query": {
"match_phrase": {
"name.pinyin": "yi"
}
},
"highlight": {
"pre_tags": [
"""<span color="red">"""
],
"post_tags": [
"</span>"
],
"fields": {
"*": {}
},
"fragment_size": 2147483647
}
}
结果:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 0.8025915,
"hits" : [
{
"_index" : "test",
"_type" : "_doc",
"_id" : "1",
"_score" : 0.8025915,
"_source" : {
"name" : "一一"
},
"highlight" : {
"name.pinyin" : [
"一一"
]
}
}
]
}
}
已邀请:

medcl - 今晚打老虎。

赞同来自:

搜索的是 “yi”,高亮的是“一”,不是 OK 么?

要回复问题请先登录注册