Elasticsearch Bulk Indexing with specified index, type in URL not working

I am trying to bulk index a 45 MB file using the bulk API on Elasticsearch. The docs say 'The endpoints are /_bulk, /{index}/_bulk, and {index}/{type}/_bulk. When the index or the index/type are provided, they will be used by default on bulk items that don’t provide them explicitly.'. So, I tried this:

curl -XPOST https://example-es-cluster.com/foo/bar/_bulk --data-binary @sample.json

where foo is the index, bar is the type and sample.json holds the required data. sample.json follows all guidelines, here are the contents.

cat sample.json {"foo": "bar", "baz": "qux"} {"foo": "bar1", "baz": "qux1"}

It also has a new line at the end of the file. However, I get the error: {"error":"ActionRequestValidationException[Validation Failed: 1: no requests added;]","status":400}.

Any ideas or help please?

The docs also give the format you need to follow for bulk;

action_and_meta_data\n
optional_source\n
action_and_meta_data\n
optional_source\n
....
action_and_meta_data\n
optional_source\n

Which is not what you have.

1 Like

When the index or the index/type are provided, they will be used by default on bulk items that don’t provide them explicitly. This is what the docs say, so I shouldn't have to specify the action/metadata, right?

You still need the action though.

Thanks!