edge_ngram查询高亮问题
匿名 | 发布于2018年07月19日 | 阅读数:5684
功能:自动补全功能
问题:
搜索 "测试" ,高亮匹配的是"<em>测试数据</em>",期望的是"<em>测试</em>数据"
settings
Mapping
问题:
搜索 "测试" ,高亮匹配的是"<em>测试数据</em>",期望的是"<em>测试</em>数据"
settings
{
"my_index": {
"settings": {
"index": {
"number_of_shards": "1",
"provided_name": "my_index",
"creation_date": "1531985044696",
"analysis": {
"filter": {
"edge_ngram_filter": {
"type": "edge_ngram",
"min_gram": "1",
"max_gram": "20"
}
},
"analyzer": {
"autoAnalyzer": {
"filter": [
"edge_ngram_filter",
"lowercase"
],
"type": "custom",
"tokenizer": "keyword"
},
"ik": {
"tokenizer": "ik_max_word"
}
}
},
"number_of_replicas": "0",
"uuid": "WJ22jjdPRX6HIY3DFtgFmA",
"version": {
"created": "5050199"
}
}
}
}
}
Mapping
{
"my_index": {
"mappings": {
"my_index": {
"properties": {
"auto_title": {
"type": "text",
"store": true,
"term_vector": "with_positions_offsets",
"analyzer": "autoAnalyzer",
"search_analyzer": "standard"
},
"title": {
"type": "text",
"copy_to": [
"auto_title"
],
"analyzer": "ik_max_word"
}
}
}
}
}
}
query:GET /my_index/_search
{
"query":{
"term":{
"auto_title":"测试"
}
},
"highlight":{
"pre_tags":[
"<em>"
],
"post_tags":[
"</em>"
],
"fields":{
"auto_title":{
"type":"fvh"
}
}
},
"_source":[
]
}
搜索结果:{
"took": 0,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 3.9417796,
"hits": [
{
"_index": "zhuanti",
"_type": "zhuanti",
"_id": "953",
"_score": 3.9417796,
"_source": {
"title": "测试数据",
"special_type": "2",
"description": "测试顶部专测试顶部专测试顶部专",
"status": "3",
"id": "953",
"create_time": "1520495313"
},
"highlight": {
"auto_title": [
"<em>测试数据</em>"
]
}
}
]
}
}
这里我希望高亮的结果是"<em>测试</em>数据",不知哪里出了问题
0 个回复