Bulk indexing errors out (only 3 document)

New to ELK stack. Trying to explore bulk indexing. I tried this command from Kibana.

I get Validation Failed error. I didn't make this up. I got it from elastick.co site for practice.
{
"error": {
"root_cause": [
{
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: index is missing;2: type is missing;"
}
],
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: index is missing;2: type is missing;"
},
"status": 400
}
POST _bulk
{"index":{"_id":"1"}}
{"account_number":1,"balance":39225,"firstname":"Amber","lastname":"Duke","age":32,"gender":"M","address":"880 Holmes Lane","employer":"Pyrami","email":"amberduke@pyrami.com","city":"Brogan","state":"IL"}
{"index":{"_id":"6"}}
{"account_number":6,"balance":5686,"firstname":"Hattie","lastname":"Bond","age":36,"gender":"M","address":"671 Bristol Street","employer":"Netagy","email":"hattiebond@netagy.com","city":"Dante","state":"TN"}

Hi @jason_smith,

Please refer to the official documentation for the bulk api. It outlines how to properly structure the request. By looking at your query, it seems like:

{"index":{"_id":"1"}}

should be something like

{ "index" : { "_index" : "test", "_type" : "_doc", "_id" : "1" } }

This data was provided by elastic.co at
Exploring Your Data | Elasticsearch Reference [6.2] | Elastic

https://raw.githubusercontent.com/elastic/elasticsearch/master/docs/src/test/resources/accounts.json

I thought it should be correct since it is from elastic.co

thank you

Note the endpoint used in the example: POST localhost:9200/bank/account/_bulk. In your code, your endpoint is POST _bulk. If you specify the index and type in the url, then you don't need it in the query.

Thanks,
Chris

Chris,
I couldn't run this file from curl. I don't how.
So I took few documents from the JSON file and ran it from Kibana without using curl.

I used the same example mentioned in :https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html

POST _bulk
{ "index" : { "_index" : "test", "_type" : "_doc", "_id" : "1" } }
{ "field1" : "value1" }
{ "delete" : { "_index" : "test", "_type" : "_doc", "_id" : "2" } }
{ "create" : { "_index" : "test", "_type" : "_doc", "_id" : "3" } }
{ "field1" : "value3" }
{ "update" : {"_id" : "1", "_type" : "_doc", "_index" : "test"} }
{ "doc" : {"field2" : "value2"} }

This query worked for me on 6.2.2

1 Like

@jason_smith,

In your example code listed, change

POST _bulk

to

POST <index_name>/<type_name>/_bulk

And replace <index_name> with the name of the index you want these documents to live and replace <type_name> with the name of the type for these documents (if you don't know what this should be, I'd recommend just using doc)

1 Like

Worked like a charm Chris!!!!!
Thank you mate.

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