0

我正在尝试创建一个具有嵌套映射的索引,但我不确定 json 数据应该是什么样子。我正在使用 kibana 版本 v 7.4.2。下面的示例有效,但是如果当我尝试添加任何嵌套映射(示例 2)时,最后会出现错误。

样品 1

PUT testIndex?pretty=true 
{
   "mappings":{
      "_doc":{
         "properties":{
            "time":{
               "type":"date",
               "format":"HH:mm:ss"
            }
         }
      }
   }
}

样品 2

PUT testIndex?pretty=true 
{
   "mappings":{
      "_doc":{
         "properties":{
            "time":{
               "type":"date",
               "format":"HH:mm:ss"
            }
         },
         "predicted":{
            "type":"nested",
            "properties":{
               "numofreq":{
                          "type":"integer"
                         }
                 }
         }
      }
   }
}

错误

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "The mapping definition cannot be nested under a type [_doc] unless include_type_name is set to true."
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "The mapping definition cannot be nested under a type [_doc] unless include_type_name is set to true."
  },
  "status": 400
}
4

1 回答 1

1

在较新版本的 elasticsearch 中不推荐指定 _doc 类型,
这应该可以使用
示例 1

PUT testindex?pretty=true 
{
  "mappings": {
    "properties": {
      "time": {
        "type": "date",
        "format": "HH:mm:ss"
      }
    }
  }
}

样品 2

PUT testindex1?pretty=true 
{
  "mappings": {
    "properties": {
      "time": {
        "type": "date",
        "format": "HH:mm:ss"
      },
      "predicted": {
        "type": "nested",
        "properties": {
          "numofreq": {
            "type": "integer"
          }
        }
      }
    }
  }
}
于 2020-06-30T17:15:14.897 回答