0
votes

I'm trying to create an index and add mappings. Here is what my data looks like:

{
  "test" : [ {
    "data" : "119050300",
    "date" : "00:00 2019-06-03"
  } ]
}

Here is my mapping command:

http://...com:5101/...060619/_mapping
    {
      "mappings": {
        "properties": {
          "date": {
            "type":   "date",
            "format": "HH:mm yyyy-MM-dd"
          },
            "data": {
            "type":   "integer"
          }
        }
      }
    }

Before I put data in I try and set the mapping. This is the error I get:

{
    "error": {
        "root_cause": [
            {
                "type": "mapper_parsing_exception",
                "reason": "Root mapping definition has unsupported parameters:  [mappings : {properties={date={format=HH:mm yyyy-MM-dd, type=date}, data={type=integer}}}]"
            }
        ],
        "type": "mapper_parsing_exception",
        "reason": "Root mapping definition has unsupported parameters:  [mappings : {properties={date={format=HH:mm yyyy-MM-dd, type=date}, data={type=integer}}}]"
    },
    "status": 400
}
1

1 Answers

1
votes

You are calling _mapping endpoint and still in your payload you are passing the mappings. I just created your mapping using below syntax and it worked for me, while If I pass mapping key in JSON payload I get the same exception

{  ---> Note I removed `mappings` key from payload
        "properties": {
            "date": {
                "type": "date",
                "format": "HH:mm yyyy-MM-dd"
            },
            "data": {
                "type": "integer"
            }
        }
}

Edit:- I just spent some more time and figured out you can pass mapping in your payload if you are creating a new index but if you are updating an existing mapping using _mapping endpoint, then it doesn't seem to accept it. Read more about here