The mapping definition cannot be nested under a type [_doc] unless include_type_name is set to true

在给ES7手动创建索引的时候,会出现 这个异常。

代码如下

PUT twitter
{
  "mappings": {
    "_doc": {
      "properties": {
        "type": { "type": "keyword" }, 
        "name": { "type": "text" },
        "user_name": { "type": "keyword" },
        "email": { "type": "keyword" },
        "content": { "type": "text" },
        "tweeted_at": { "type": "date" }
      }
    }
  }
}
The mapping definition cannot be nested under a type [_doc] unless include_type_name is set to true

这个异常是说不能在type类型上创建映射 , 在es7中已经在内部取消了, type。 只不过还保留着基本的语法留着过度,因此需要改成这下面这种方法,把索引下面的类型去掉。

PUT twitter
{
  "mappings": {
      "properties": {
        "type": { "type": "keyword" }, 
        "name": { "type": "text" },
        "user_name": { "type": "keyword" },
        "email": { "type": "keyword" },
        "content": { "type": "text" },
        "tweeted_at": { "type": "date" }
      }
  }
}

就可以解决了

交个朋友吧

The mapping definition cannot be nested under a type [_doc] unless include_type_name is set to true_第1张图片

你可能感兴趣的:(elasticSearch)