【发布时间】:2019-09-09 06:42:48
【问题描述】:
在下面的 ElasticSearch 中,我在 name 和 notes 两个字段中搜索单词 Balances:
GET /_search
{ "query": {
"multi_match": { "query": "Balances",
"fields": ["name","notes"]
}
}
}
name 字段中的结果:
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 1.673515,
"hits" : [
{
"_index" : "idx",
"_type" : "_doc",
"_id" : "25",
"_score" : 1.673515,
"_source" : {
"name" : "Deposits checking accounts balances",
"notes" : "These are the notes",
"@timestamp" : "2019-04-18T21:05:00.387Z",
"id" : 25,
"@version" : "1"
}
}
]
}
现在,我想知道 ElasticSearch 在哪个字段中找到了值。我可以评估结果并查看搜索到的文本是否在 name 或 notes 中,但如果是模糊搜索,我就不能这样做。
ElasticSearch 能否告诉我在哪个字段中找到了文本,另外提供一个在结果左右各 5 个单词的 sn-p 来告诉用户为什么结果是命中?
我想要实现的类似于 Google 以粗体突出显示在短语中找到的文本。
【问题讨论】:
标签: elasticsearch