ES/Kibana 5.6: why this request doesn't work?

Hello,

In the Kibana 5.6 console, development tools, I'm doing the following request:

PUT test/_mapping
{
"properties" : {
"id" : {"type" : "keyword"},
"date" : {"type" : "date"},
"customer_id" : {"type" : "keyword"},
"sent" : {"type" : "boolean"},
"name" : {"type" : "keyword"},
"quantity" : {"type" : "integer"},
"vat" : {"type" : "double", "index":"false"}
}
}

And here is the response:

{
"error": {
"root_cause": [
{
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: mapping type is missing;"
}
],
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: mapping type is missing;"
},
"status": 400
}

However, it's supposed to work as I'm using the samples in the "ElasticSearch Cookbook 4th Edition" by Alberto Paro, publshed at Packt in march 2019.
Could anyone shad some light here please ?
Many thanks in advance.
Kind regards,
Nicolas

The problem is the one highlighted in the error message. You're missing the type of the mapping.

In older versions of elasticsearch the type of mapping was mandatory and required.

So you can either do something like:

PUT test/_mapping/your_type_of_mapping
{
  "properties" : {
    "id" : {"type" : "keyword"},
    "date" : {"type" : "date"},
    "customer_id" : {"type" : "keyword"},
    "sent" : {"type" : "boolean"},
    "name" : {"type" : "keyword"},
    "quantity" : {"type" : "integer"},
    "vat" : {"type" : "double", "index":"false"}
  }
}

Or you do something like

PUT test 
{
  "mappings": {
    "your_type_of_mapping": {
      "properties" : {
        "id" : {"type" : "keyword"},
        "date" : {"type" : "date"},
        "customer_id" : {"type" : "keyword"},
        "sent" : {"type" : "boolean"},
        "name" : {"type" : "keyword"},
        "quantity" : {"type" : "integer"},
        "vat" : {"type" : "double", "index":"false"}
      }
    }
  }
}

In both cases you have to specify the type of mapping you're trying to apply.

I personally don't know the book but maybe it is written for a newer version of the stack (>= 7.0 possibly).

Hello, thanks for replying. I've upgraded to ELK 7.2.5 and the given syntax is working.
Kind regards,
Nicolas

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.