您当前的位置: 首页 >  ar

Dongguo丶

暂无认证

  • 1浏览

    0关注

    472博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

ElasticSearch 7.X.0 Root mapping definition has unsupported parameters

Dongguo丶 发布时间:2021-10-31 08:13:18 ,浏览量:1

新建索引

PUT forum
{
  "mappings": {
    "article" : {
      "properties" : {
        "articleID" : {
          "type" : "keyword"
        }
      }
    }
  }

然后,报错: Root mapping definition has unsupported parameters: [article : {properties={articleID={type=keyword}}}]

{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "Root mapping definition has unsupported parameters:  [article : {properties={articleID={type=keyword}}}]"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [article : {properties={articleID={type=keyword}}}]",
    "caused_by" : {
      "type" : "mapper_parsing_exception",
      "reason" : "Root mapping definition has unsupported parameters:  [article : {properties={articleID={type=keyword}}}]"
    }
  },
  "status" : 400
}

查看官网示例后发现 7.X 默认不在支持指定索引类型,默认索引类型是_doc(隐含:include_type_name=false)。见官网: Removal of mapping types 在这里插入图片描述 修改:

PUT forum
{
  "mappings": {
 
      "properties" : {
        "articleID" : {
          "type" : "keyword"
        }
      }
    
  }

返回响应

{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "index" : "forum"
}

如果你要像之前旧版版本一样兼容自定义 type ,需要将 include_type_name=true 携带, 见官网示例: index templates

重建索引

#注意:这里是把索引删了,数据也就没了
DELETE forum

PUT forum?include_type_name=true
{
  "mappings": {
    "article" : {
      "properties" : {
        "articleID" : {
          "type" : "keyword"
        }
      }
    }
  }

返回响应

#! Deprecation: [types removal] Using include_type_name in create index requests is deprecated. The parameter will be removed in the next major version.
{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "index" : "forum"
}

但是这一字段将在8.x 舍弃

关注
打赏
1638062488
查看更多评论
立即登录/注册

微信扫码登录

0.0426s