【问题标题】:how to properly nest mappings in an index in kibana?如何在kibana的索引中正确嵌套映射?
【发布时间】:2020-10-21 01:18:22
【问题描述】:

我正在尝试创建一个具有嵌套映射的索引,但我不确定 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
}

【问题讨论】:

    标签: amazon-web-services elasticsearch kibana kibana-7


    【解决方案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"
              }
            }
          }
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-19
      • 1970-01-01
      • 2018-11-17
      • 1970-01-01
      • 2018-05-12
      相关资源
      最近更新 更多