zoukankan      html  css  js  c++  java
  • Root mapping definition has unsupported parameters

    使用ElasticSearch创建映射报错

    Root mapping definition has unsupported parameters
    

    原因

    使用的ES版本为7.2.0,不再支持创建指定类型,索引的默认类型为_doc.
    官网图片

    解决办法

    创建索引的映射时,不需要指定类型即可

    错误再现

    错误的创建索引语句

    PUT /dangdang1
    {
      "mappings": {
        "book":{  # 这里指定了类型type
          "properties": {
            "id": {
              "type": "integer"
            },
            "name": {
              "type": "keyword"
            },
            "price": {
              "type": "double"
            },
            "detail": {
              "type": "text"
            }
          }
        }
      }
    }
    

    报错信息

    {
      "error": {
        "root_cause": [
          {
            "type": "mapper_parsing_exception",
            "reason": "Root mapping definition has unsupported parameters:  [book : {properties={price={type=double}, name={type=keyword}, id={type=integer}, detail={type=text}}}]"
          }
        ],
        "type": "mapper_parsing_exception",
        "reason": "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [book : {properties={price={type=double}, name={type=keyword}, id={type=integer}, detail={type=text}}}]",
        "caused_by": {
          "type": "mapper_parsing_exception",
          "reason": "Root mapping definition has unsupported parameters:  [book : {properties={price={type=double}, name={type=keyword}, id={type=integer}, detail={type=text}}}]"
        }
      },
      "status": 400
    }
    

    正确的创建索引映射的语句

    PUT /dangdang
    {
      "mappings": {
          # 这里不再写类型
          "properties": {
            "id": {
              "type": "integer"
            },
            "name": {
              "type": "keyword"
            },
            "price": {
              "type": "double"
            },
            "detail": {
              "type": "text"
            }
          }
      }
    }
    
  • 相关阅读:
    django ---解决跨域的问题
    python-isinstance函数
    python每日一学-os模块常用函数
    调用父类方法super
    fiddler小运用-断点
    劝告
    Django model字段
    Jenkins自动化部署前端
    解决react使用antd table组件固定表头后,表头和表体列不对齐以及配置fixed固定左右侧后行高度不对齐
    高德地图判断点的位置是否在浏览器可视区域内
  • 原文地址:https://www.cnblogs.com/juyss/p/14033657.html
Copyright © 2011-2022 走看看