【问题标题】:Get from ElasticSearch why a result is a hit从 ElasticSearch 获取为什么结果很受欢迎
【发布时间】:2019-09-09 06:42:48
【问题描述】:

在下面的 ElasticSearch 中,我在 namenotes 两个字段中搜索单词 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 在哪个字段中找到了值。我可以评估结果并查看搜索到的文本是否在 namenotes 中,但如果是模糊搜索,我就不能这样做。

ElasticSearch 能否告诉我在哪个字段中找到了文本,另外提供一个在结果左右各 5 个单词的 sn-p 来告诉用户为什么结果是命中?

我想要实现的类似于 Google 以粗体突出显示在短语中找到的文本。

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    我认为Find out which fields matched in a multi match query 中的 2 个解决方案仍然是有效的解决方案:

    • 突出显示以找到它。
    • 将查询拆分为多个命名匹配查询。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-01-20
      • 1970-01-01
      • 2015-05-23
      • 2019-06-11
      • 2021-04-04
      • 2020-10-25
      • 1970-01-01
      相关资源
      最近更新 更多