0

早些时候我使用的是 1.x 版本,并使用以下语法创建子对象映射。

"foo": {
            "type": "integer",
            "doc_values": true
        },
"foo.bar": {
            "type": "integer",
            "doc_values": true
        },
"foo.bar.baz": {
            "type": "integer",
            "doc_values": true
        },

但是现在当我在 ES 7.x 中使用相同的映射语法时,我遇到了以下错误:-

{
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "Can't merge a non object mapping [foo] with an object mapping [foo]"
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "Can't merge a non object mapping [foo] with an object mapping [foo]"
    },
    "status": 400
}

我来到了这个 SO 帖子Can't merge a non object mapping with an object mapping error in machine learning(beta) module但是,请注意我没有更新映射,而是我正在创建一个新的映射仍然得到这个错误,拜托建议怎么办?

4

1 回答 1

0

对象类型的示例。请参阅此处了解更多信息

"mappings": {
    "properties": { 
      "user": { 
        "properties": {
          "age":  { "type": "integer" },
          "name": { 
            "properties": {
              "first": { "type": "text" },
              "last":  { "type": "text" }
            }
          }
        }
      }
    }

在下面的名称可以定义为对象,并且可以使用 name.firstname 等添加更多属性。在您的映射中,foo 是整数类型,然后您添加 foo.bar,因此它会引发错误。foo 必须是对象类型。

"properties" : {
            "name" : {
                "type" : "object"
            },
            "name.firstname":{
              "type" : "text"
            },
            "name.lastname":{
              "type" : "text"
            }
        }
于 2019-06-19T09:13:26.617 回答