Elasticsearch对象映射,试图将字段[null]解析为对象,但发现了具体值 [英] Elasticsearch object mapping for tried to parse field [null] as object, but found a concrete value

查看:250
本文介绍了Elasticsearch对象映射,试图将字段[null]解析为对象,但发现了具体值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用AWS上的Elasticsearch更改映射或输入以解决这些错误,

How can I change mapping or my input to resolve these error, using elasticsearch on AWS,

映射:

{
    "index_patterns": ["*-students-log"],
    "mappings": {
        "properties": {
            "Data": {
                "type": "object",
                "properties": {
                    "PASSED": {
                        "type": "object"
                    }
                }
            },
            "insertion_timestamp": {
                "type": "date",
                "format": "epoch_second"
            }
        }
    }
}

我的数据:

curl -XPOST -H 'Content-Type: application/json' https://******.us-east-1.es.amazonaws.com/index_name/_doc/1 -d '{"Data": {"PASSED": ["Vivek"]},"insertion_timestamp": 1591962493}'

我遇到错误:

{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"object mapping for [Data.PASSED] tried to parse field [null] as object, but found a concrete value"}],"type":"mapper_parsing_exception","reason":"object mapping for [Data.PASSED] tried to parse field [null] as object, but found a concrete value"},"status":400}

上述数据中缺失或错误的部分是什么?我还应该将其他数据类型用于字符串数组吗?任何帮助将不胜感激...

What is the missing or wrong piece in the above data? Is there any other datatype I should use for array of string? Any help would be appreciated...

推荐答案

JSON 数组被导入ES时不被视为JSON 对象,因此该错误是有道理的.


数组上的文档清晰明了:

The docs are clear on arrays:

没有专用的数组数据类型.任何字段都可以包含零或默认情况下,更多的值,但是,数组中的所有值都必须是相同的数据类型.

There is no dedicated array datatype. Any field can contain zero or more values by default, however, all values in the array must be of the same datatype.

话虽如此,以下情况适用于您的情况:

Having said that, the following would work in your case:

PUT abc-students-log
{
  "mappings": {
    "properties": {
      "Data": {
        "type": "object",
        "properties": {
          "PASSED": {
            "type": "text"   
          }
        }
      },
      "insertion_timestamp": {
        "type": "date",
        "format": "epoch_second"
      }
    }
  }
}

POST abc-students-log/_doc
{
  "Data": {
    "PASSED": [
      "Vivek"
    ]
  },
  "insertion_timestamp": 1591962493
}

这篇关于Elasticsearch对象映射,试图将字段[null]解析为对象,但发现了具体值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆