# Bulk indexing errors out (only 3 document)

**URL:** <https://discuss.elastic.co/t/bulk-indexing-errors-out-only-3-document/122599>\
**Category:** Kibana\
**Created:** [March 5, 2018, 9:33pm UTC](https://discuss.elastic.co/t/bulk-indexing-errors-out-only-3-document/122599 "2018-03-05T21:33:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason\_smith](https://avatars.discourse-cdn.com/v4/letter/j/b5e925/32.png) [@jason\_smith](https://discuss.elastic.co/u/jason_smith)\
**Post date:** [March 5, 2018, 9:33pm UTC](https://discuss.elastic.co/t/bulk-indexing-errors-out-only-3-document/122599/1 "2018-03-05T21:33:25Z")

</div>

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](http://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](mailto:Lane%22,%22employer%22:%22Pyrami%22,%22email%22:%22amberduke@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](mailto:Street%22,%22employer%22:%22Netagy%22,%22email%22:%22hattiebond@netagy.com)","city":"Dante","state":"TN"}

---

<div class="post-metadata">

**Author:** ![chrisronline](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrisronline/32/28230_2.png) [@chrisronline](https://discuss.elastic.co/u/chrisronline)\
**Post date:** [March 5, 2018, 10:00pm UTC](https://discuss.elastic.co/t/bulk-indexing-errors-out-only-3-document/122599/2 "2018-03-05T22:00:41Z")

</div>

Hi @jason_smith,

Please refer to [the official documentation for the bulk api](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html). It outlines how to properly structure the request. By looking at your query, it seems like:

```auto
{"index":{"_id":"1"}}

```

should be something like

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

```

---

<div class="post-metadata">

**Author:** ![jason\_smith](https://avatars.discourse-cdn.com/v4/letter/j/b5e925/32.png) [@jason\_smith](https://discuss.elastic.co/u/jason_smith)\
**Post date:** [March 5, 2018, 10:06pm UTC](https://discuss.elastic.co/t/bulk-indexing-errors-out-only-3-document/122599/3 "2018-03-05T22:06:24Z")

</div>

> [@jason\_smith](#):
>
> Validation Failed error

This data was provided by [elastic.co](http://elastic.co) at  
[Exploring Your Data | Elasticsearch Reference [6.2] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/_exploring_your_data.html)

[https://raw.githubusercontent.com/elastic/elasticsearch/master/docs/src/test/resources/accounts.json](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](http://elastic.co)

thank you

---

<div class="post-metadata">

**Author:** ![chrisronline](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrisronline/32/28230_2.png) [@chrisronline](https://discuss.elastic.co/u/chrisronline)\
**Post date:** [March 5, 2018, 10:23pm UTC](https://discuss.elastic.co/t/bulk-indexing-errors-out-only-3-document/122599/4 "2018-03-05T22:23:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jason\_smith](https://avatars.discourse-cdn.com/v4/letter/j/b5e925/32.png) [@jason\_smith](https://discuss.elastic.co/u/jason_smith)\
**Post date:** [March 5, 2018, 10:26pm UTC](https://discuss.elastic.co/t/bulk-indexing-errors-out-only-3-document/122599/5 "2018-03-05T22:26:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rashmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashmi/32/16391_2.png) [@rashmi](https://discuss.elastic.co/u/rashmi)\
**Post date:** [March 5, 2018, 11:11pm UTC](https://discuss.elastic.co/t/bulk-indexing-errors-out-only-3-document/122599/6 "2018-03-05T23:11:18Z")

</div>

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

```auto
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

---

<div class="post-metadata">

**Author:** ![chrisronline](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrisronline/32/28230_2.png) [@chrisronline](https://discuss.elastic.co/u/chrisronline)\
**Post date:** [March 5, 2018, 11:27pm UTC](https://discuss.elastic.co/t/bulk-indexing-errors-out-only-3-document/122599/7 "2018-03-05T23:27:53Z")

</div>

@jason_smith,

In your example code listed, change

```auto
POST _bulk

```

to

```auto
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`)

---

<div class="post-metadata">

**Author:** ![jason\_smith](https://avatars.discourse-cdn.com/v4/letter/j/b5e925/32.png) [@jason\_smith](https://discuss.elastic.co/u/jason_smith)\
**Post date:** [March 6, 2018, 1:02am UTC](https://discuss.elastic.co/t/bulk-indexing-errors-out-only-3-document/122599/8 "2018-03-06T01:02:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 3, 2018, 1:02am UTC](https://discuss.elastic.co/t/bulk-indexing-errors-out-only-3-document/122599/9 "2018-04-03T01:02:45Z")

</div>

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