Validation failed because of missing type with bulk API


I would like to add the following JSON file using the bulk API


however I get the following error

"type" : "action_request_validation_exception",
"reason" : "Validation Failed: 1: type is missing;"

I did the following in the Kibana console So I don't see why I'm getting a mistake:

PUT /fake
 "mappings": {
  "doc": {
   "properties": {
    "info": {"type": "keyword"}

It looks like your payload is not properly formed. It must look like this:

POST /your_index/your_type/_bulk


POST /_bulk
{"index":{"_index": "your_index", "_type": "your_type", "_id":"1"}}
1 Like

OK. But how Do I make this work from the terminal? Because in practice, I will want to add a much bigger JSON file.

If I understand correctly, in your' solution, you are not passing through a separate file.

You can do exactly the same from the terminal.

Create a bulk file with this content (also make sure that there is a newline on the last line):

{"index":{"_index": "your_index", "_type": "your_type", "_id":"1"}}
{"index":{"_index": "your_index", "_type": "your_type", "_id":"2"}}
{"index":{"_index": "your_index", "_type": "your_type", "_id":"3"}}

Then you can use curl to send that file to the _bulk endpoint like this:

curl -XPOST -H 'Content-Type: application/json' localhost:9200/_bulk --data-binary @/path/to/your_file.json

Thanks this works very well.

(Maybe it's better if I open a new subject)

Is the type then defined as the same for each element in the line (in case I have multiple elements)?

I was wondering also what the different types were?

I know integer and keyword. Is there a type for "indentation"?

Like if I would have my JSON file like this:


Plus is there a way of defining the type and index once and for all for a JSON file (because it will be the same thing for each line)

I guess it's better to ask another question, so we can keep a single subject per question.
Feel free to reference your new question from this one, though.

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