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"
            }
          }
      }
    }
    
  • 相关阅读:
    create-react-app
    简单的PHP的任务队列
    Yii框架中使用PHPExcel导出Excel文件
    Android 使用全局变量的问题
    Android 退出整个应用程序
    new DialogInterface.OnClickListener()报错的解决办法
    Yii 日期时间过滤列 filter
    Yii 时间戳格式化显示的问题
    PullToRefreshListView 应用讲解
    Android:Layout_weight的深刻理解
  • 原文地址:https://www.cnblogs.com/juyss/p/14033657.html
Copyright © 2011-2022 走看看