首页 > 解决方案 > 千分尺无法将指标保存到弹性搜索,因为最终映射将具有超过 1 种类型:[_doc, doc]

问题描述

我正在尝试实施 Micrometer Elasticsearch 注册表,但出现以下错误

      {
    "took": 158,
    "errors": true,
    "items": [
      {
        "index": {
          "_index": "metrics-2019-11",
          "_type": "doc",
          "_id": "PDzhNm4BiJBtovrbDFDF",
          "status": 400,
          "error": {
            "type": "illegal_argument_exception",
            "reason": "Rejecting mapping update to [metrics--2019-11] as the final mapping would have more than 1 type: [_doc, doc]"
          }
        }
      },
      {
        "index": {
          "_index": "metrics--2019-11",
          "_type": "doc",
          "_id": "PTzhNm4BiJBtovrbDFDF",
          "status": 400,
          "error": {
            "type": "illegal_argument_exception",
            "reason": "Rejecting mapping update to [metrics--2019-11] as the final mapping would have more than 1 type: [_doc, doc]"
          }
        }
      }
    ]
  }

我不得不说我不太了解这个错误,千分尺是否试图将同一个文档推送到 2 个不同的键(doc 和 _doc)?

我在文档中没有看到任何关于文档类型或其密钥或任何相关内容的信息

同样,索引没有事先创建,我让千分尺创建它们,所以这怎么行不通。

弹性搜索 7.4.2

千分尺 1.2.1

春季启动 2.1.2

标签: spring-bootelasticsearchmicrometer

解决方案


spring-boot-gradle-plugin我在使用不兼容版本的和时遇到了这个错误mavenBom

例如,我的 build.gradle 文件中有以下内容:

buildscript {
...
    dependencies {
        classpath "org.springframework.boot:spring-boot-gradle-plugin:2.2.5.RELEASE"
    }
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:Greenwich.SR1"
    }
}

但是2.2.5.RELEASEGreenwich.SR1不在同一个版本的火车上。更改“Bom”版本以Hoxton.SR1解决问题。

即使您没有使用 gradle,问题也可能是由于不兼容的依赖版本。


推荐阅读