【问题标题】:Highlight hits within attachment content with ElasticSearch使用 ElasticSearch 突出显示附件内容中的命中
【发布时间】:2015-02-05 13:33:26
【问题描述】:

我无法让 ElasticSearch 突出显示使用 elasticsearch-mapper-attachments 索引的附件内容中的命中。

我在/stuff/file 的数据如下所示:

{
    "id": "string"
    "name": "string"
    "attachment": "...base 64 encoded file"
}

我的映射器配置放到/stuff/file/_mapper 看起来像这样:

{
    "file" : {
        "properties" : {
            "attachment" : {  
                "type" : "attachment",
                "path" : "full",
                "fields": {
                    "name": { "store": true },
                    "title": { "store": true },
                    "content": { "store": true },
                    "attachment": {
                        "type": "string",
                        "term_vector": "with_positions_offsets",
                        "store": true
                    }
                }
            }
        }
    }
}

当我在 /stuff/_mapper/file 查询它时,我得到了返回:

{
   "stuff":{
      "mappings":{
         "file":{
            "properties":{
               "attachment":{
                  "type":"attachment",
                  "path":"full",
                  "fields":{
                     "attachment":{
                        "type":"string"
                     },
                     "author":{
                        "type":"string"
                     },
                     "title":{
                        "type":"string"
                     },
                     "name":{
                        "type":"string"
                     },
                     "date":{
                        "type":"date",
                        "format":"dateOptionalTime"
                     },
                     "keywords":{
                        "type":"string"
                     },
                     "content_type":{
                        "type":"string"
                     },
                     "content_length":{
                        "type":"integer"
                     },
                     "language":{
                        "type":"string"
                     }
                  }
               },
               "id":{
                  "type":"string"
               },
               "name":{
                  "type":"string"
               }
            }
         }
      }
   }
}

我的查询如下所示:

{
    "size": 30,
    "query": {
        "multi_match": {
            "query": "{{.Query}}",
            "operator": "and",
            "fields": ["id", "name^4", "attachment"],
            "fuzziness": "AUTO",
            "minimum_should_match": "80%"
        }
    },
    "highlight" : {
        "fields" : {
            "attachment": { }
        }
    }
}

当我搜索附件中的术语时,它会返回正确的结果,但没有突出显示。几年前有一个类似的问题,在一些地方将 attachment 替换为 file,但有一些 cmets 再次改变了......让突出显示工作的正确配置是什么?

【问题讨论】:

  • 我有同样的问题...弹性搜索 1.7 不支持附件突出显示?

标签: elasticsearch attachment highlight


【解决方案1】:

事实证明,您无法使用 PUT 覆盖映射器配置。需要先删除已有的配置(我其实已经删除了整个数据库,DELETE对配置好像没有任何效果)。映射器配置实际更新后,突出显示就可以正常工作了。

【讨论】:

    猜你喜欢
    • 2018-04-12
    • 1970-01-01
    • 2014-10-23
    • 2017-01-02
    • 1970-01-01
    • 1970-01-01
    • 2013-05-22
    • 2016-02-24
    • 2019-09-10
    相关资源
    最近更新 更多