0

Earlier I was using 1.x version and was creating the sub objects mapping using below syntax.

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

But now when I am using same mapping syntax in ES 7.x I am getting below error:-

{
    "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
}

I am came accros this SO post Can’t merge a non object mapping with an object mapping error in machine learning(beta) module But, Note I am not updating the mapping, instead I am crating a new mapping still getting this error, please advise what to do?

1 Answers1

0

An example of object type. Refer here for more info

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

In below name can be defined as object and further properties can be added using name.firstname etc. In your mapping foo is of type integer and then you are adding foo.bar so it is throwing error. foo must be of type object.

"properties" : {
            "name" : {
                "type" : "object"
            },
            "name.firstname":{
              "type" : "text"
            },
            "name.lastname":{
              "type" : "text"
            }
        }
jaspreet chahal
  • 8,817
  • 2
  • 11
  • 29
  • I looked into this, but then in this format, I have to change a lot, I wanted to know if there is any possibility that it works with existing format –  Jun 19 '19 at 09:25
  • Thanks for providing some simple syntax, but It would still require some changes and I would like to know why it worked in ES 1.x while I don't see there is any breaking changes in this regard –  Jun 19 '19 at 11:12
  • In 1.x mapping syntax is similar to 7 . I am not able to understand how it worked. https://www.elastic.co/guide/en/elasticsearch/guide/1.x/complex-core-fields.html – jaspreet chahal Jun 19 '19 at 11:19
  • Exactly thats my worry as it involve lot of syntax change which I want to avoid –  Jun 19 '19 at 12:41
  • https://www.elastic.co/guide/en/elasticsearch/reference/2.4/dots-in-names.html. According to this article you will have to update mapping to object type – jaspreet chahal Jun 19 '19 at 13:52
  • One trivial solution could be to replace . with _ in field names and in subsequently in search queries. Please upvote if this helped – jaspreet chahal Jun 20 '19 at 03:34
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/195238/discussion-between-user7851946-and-jaspreet-chahal). –  Jun 20 '19 at 04:46