es5.6和7.6关于高亮的语法差别?
匿名 | 发布于2020年09月15日 | 阅读数:2184
相同的mappings和查询语句,在7.6版本上可以返回高亮字段,在5.6版本上无法返回高亮字段,想问问大佬,如何在5.6上返回高亮字段,是语法上的差别还是5.6就不支持?
# 索引创建语句
PUT example/docs/1
{
"region": "CN",
"manager": {
"age": 22,
"name": {
"first": "李",
"last": "小明"
}
}
}
# 查询语句
GET example/_search
{
"highlight": {
"fields": {
"manager.name.last": {},
"manager.name.first": {}
}
},
"query": {
"query_string": {
"query": "李小明"
}
}
}
# es7.6返回结果,有高亮字段
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 0.5753642,
"hits" : [
{
"_index" : "example",
"_type" : "docs",
"_id" : "1",
"_score" : 0.5753642,
"_source" : {
"region" : "CN",
"manager" : {
"age" : 22,
"name" : {
"first" : "李",
"last" : "小明"
}
}
},
"highlight" : {
"manager.name.first" : [
"<em>李</em>"
],
"manager.name.last" : [
"<em>小</em><em>明</em>"
]
}
}
]
}
}
# es5.6返回结果,无高亮字段
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.84748024,
"hits": [
{
"_index": "example",
"_type": "docs",
"_id": "1",
"_score": 0.84748024,
"_source": {
"region": "CN",
"manager": {
"age": 22,
"name": {
"first": "李",
"last": "小明"
}
}
}
}
]
}
}
0 个回复