4

I am posting to my nearly created Elasticsearch service, but unable to post the mapping. I can not identify which part is unsupported. Any suggestions?

{
    "mappings": {
        "employees": {
            "properties": {
                "FirstName": {
                    "type": "text"
                },
                "LastName": {
                    "type": "text"
                },
                "Designation": {
                    "type": "text"
                },
                "Salary": {
                    "type": "integer"
                },
                "DateOfJoining": {
                    "type": "date",
                    "format": "yyyy-MM-dd"
                },
                "Address": {
                    "type": "text"
                },
                "Gender": {
                    "type": "text"
                },
                "Age": {
                    "type": "integer"
                },
                "MaritalStatus": {
                    "type": "text"
                },
                "Interests": {
                    "type": "text"
                }
            }
        }
    }
}

I consistently get this error returned.

{
    "error": {
        "root_cause": [
            {
                "type": "mapper_parsing_exception",
                "reason": "Root mapping definition has unsupported parameters:  [employees : {properties={Designation={type=text}, Salary={type=integer}, MaritalStatus={type=text}, DateOfJoining={format=yyyy-MM-dd, type=date}, Address={type=text}, FirstName={type=text}, LastName={type=text}, Gender={type=text}, Age={type=integer}, Interests={type=text}}}]"
            }

Using Version 7.6.2

Amit
  • 30,756
  • 6
  • 57
  • 88
bensd
  • 47
  • 2
  • 7

2 Answers2

6

As you didn't specify your Elasticsearch version, which I also asked in my comment,

I have multiple versions of Elasticsearch and as you are using text, I started with Elasticsearch 7 as, you also specified employees in your mapping, which created suspect as this is normally defined in older versions, where types are defined.

Please see removal of types official doc for more info and not it would be completely removed in coming major version of 8.X

I was able to reproduce the issue with Elasticsearch 7.6 and got the same error:

 "error": {
        "root_cause": [
            {
                "type": "mapper_parsing_exception",
                "reason": "Root mapping definition has unsupported parameters:  [employees : {properties={Designation={type=text}, Salary={type=integer}, MaritalStatus={type=text}, DateOfJoining={format=yyyy-MM-dd, type=date}, Address={type=text}, FirstName={type=text}, LastName={type=text}, Gender={type=text}, Age={type=integer}, Interests={type=text}}}]"
            }
        ],
        "type": "mapper_parsing_exception",
        "reason": "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [employees : {properties={Designation={type=text}, Salary={type=integer}, MaritalStatus={type=text}, DateOfJoining={format=yyyy-MM-dd, type=date}, Address={type=text}, FirstName={type=text}, LastName={type=text}, Gender={type=text}, Age={type=integer}, Interests={type=text}}}]",
        "caused_by": {
            "type": "mapper_parsing_exception",
            "reason": "Root mapping definition has unsupported parameters:  [employees : {properties={Designation={type=text}, Salary={type=integer}, MaritalStatus={type=text}, DateOfJoining={format=yyyy-MM-dd, type=date}, Address={type=text}, FirstName={type=text}, LastName={type=text}, Gender={type=text}, Age={type=integer}, Interests={type=text}}}]"
        }
    },
    "status": 400
}

Solution

Simply remove the employee from your mapping and use below mapping.

{
    "mappings": {
        "properties": { --> note `employees` removed.
            "FirstName": {
                "type": "text"
            },
            "LastName": {
                "type": "text"
            },
            "Designation": {
                "type": "text"
            },
            "Salary": {
                "type": "integer"
            },
            "DateOfJoining": {
                "type": "date",
                "format": "yyyy-MM-dd"
            },
            "Address": {
                "type": "text"
            },
            "Gender": {
                "type": "text"
            },
            "Age": {
                "type": "integer"
            },
            "MaritalStatus": {
                "type": "text"
            },
            "Interests": {
                "type": "text"
            }
        }
    }
}

Above create index successfully

{
    "acknowledged": true,
    "shards_acknowledged": true,
    "index": "mustnot"
}
Amit
  • 30,756
  • 6
  • 57
  • 88
1

You seem to be using version 7.x of Elasticsearch, which doesn't support mapping types anymore. You simply need to remove employees, like this:

{
  "mappings": {
    "properties": {
      "FirstName": {
        "type": "text"
      },
      "LastName": {
        "type": "text"
      },
      "Designation": {
        "type": "text"
      },
      "Salary": {
        "type": "integer"
      },
      "DateOfJoining": {
        "type": "date",
        "format": "yyyy-MM-dd"
      },
      "Address": {
        "type": "text"
      },
      "Gender": {
        "type": "text"
      },
      "Age": {
        "type": "integer"
      },
      "MaritalStatus": {
        "type": "text"
      },
      "Interests": {
        "type": "text"
      }
    }
  }
}
Val
  • 207,596
  • 13
  • 358
  • 360
  • you beat me in this , I was asking for ES version and started repro the issue and you just posted answer within 3 mins of posting question, amazing ‍♂️, missed it by few seconds , hope one day I would beat you in this race – Amit Apr 07 '20 at 14:05
  • @OpsterElasticsearchNinja rest assured, it's not a race, there's no final line ;-) – Val Apr 07 '20 at 14:08
  • Ha ha, but its a game for sure :) – Amit Apr 07 '20 at 14:09