首页 > 解决方案 > 映射附件在 Elasticsearch 7.7 中引发错误

问题描述

我尝试将该字段映射为用户定义的字段 - 弹性搜索中的“附件”,如下所示

"file": {
            "type": "attachment",
            "fields": {
              "content": {
                "type": "text"
              },
              "author": {
                "type": "text",
                "store": true
              }
}

附件映射如下,

"attachment": {
            "properties": {
              "author": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "content": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }

但我收到以下错误:

java.util.concurrent.ExecutionException: RemoteTransportException[[3cfb4e163654][172.17.0.2:9300][indices:admin/create]]; nested: MapperParsingException[Failed to parse mapping [mappings]: No handler for type [attachment] declared on field [file]]; nested: MapperParsingException[No handler for type [attachment] declared on field [file]];

[无法解析映射 [mappings]:没有在字段 [file] 上声明的类型 [attachment] 的处理程序]

我已经将摄取附件插件添加到弹性搜索插件中,当我在弹性搜索中列出插件时它可用。

我的映射有什么问题?

请帮我解决这个问题?

谢谢,
哈利

标签: elasticsearchelasticsearch-pluginelasticsearch-7

解决方案


您已经安装了该插件,并且在您列出它时可用。但是你得到了错误No handler for type [attachment] declared on field [file]

原因:

您期望添加attachment为一种类型。但事实并非如此。

摄取附件插件不添加新类型。但增加了一个摄取处理器

参考

您需要将其添加为管道中的处理器。

更新1:

仅安装插件并不能解决问题,因为它是无效类型。我能够重现此错误。

参考文档是上面的链接是我在原始答案中附加的链接。

关于使用方式的很好的解释


推荐阅读