# Bulk Indexing via REST

**URL:** https://discuss.elastic.co/t/bulk-indexing-via-rest/12285
**Category:** Elasticsearch
**Created:** [June 5, 2013, 5:16pm UTC](https://discuss.elastic.co/t/bulk-indexing-via-rest/12285 "2013-06-05T17:16:24Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![samCougars](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@samCougars](https://discuss.elastic.co/u/samCougars)
#### Post date: [June 5, 2013, 5:16pm UTC](https://discuss.elastic.co/t/bulk-indexing-via-rest/12285/1 "2013-06-05T17:16:24Z")

</div>

All,

I'm hitting this url "[http://localhost:9200/\_bulk](http://localhost:9200/_bulk)" on my local elasticSearch. Thru http PUT METHOD, I'm sending following JSON:  
{ "index" : { "\_index" : "dev1\_m1\_conference", "\_type" : "en\_exhibitor", "\_id" : "1142" } }  
{"name":"Exhibitor2","type":"Silver Sponsor","description":"exhibitor description. exhibitor description. exhibitor description. exhibitor description. exhibitor description. exhibitor description. exhibitor description. exhibitor description. exhibitor description.","nameSort":"Exhibitor2","typeSort":"SilverSponsor","website":null,"boothNameNum":"","published":"exhibitorPublished","206":"","205":"","cv":""}  
{ "index" : { "\_index" : "dev1\_m1\_conference", "\_type" : "en\_exhibitor", "\_id" : "1143" } }  
{"name":"Exhibitor3","type":"Gold Sponsor","description":"exhibitor description. exhibitor description. exhibitor description. exhibitor description. exhibitor description. exhibitor description. exhibitor description. exhibitor description. exhibitor description.","nameSort":"Exhibitor3","typeSort":"GoldSponsor","website":null,"boothNameNum":"","published":"exhibitorPublished","206":"","205":"","cv":""}

But, it seems like it is indexing ONLY first element of id = 1142. I know this for sure because when I hit this URL "[http://localhost:9200/dev1\_m1\_conference/en\_exhibitor/\_search](http://localhost:9200/dev1_m1_conference/en_exhibitor/_search)", it returns me the first element as a result.

Am I missing something while doing REST bulk indexing?

Thanks,

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [June 6, 2013, 8:00am UTC](https://discuss.elastic.co/t/bulk-indexing-via-rest/12285/2 "2013-06-06T08:00:26Z")

</div>

Hey,

can you put a gist, so that we can take your data and reconstruct the  
problem properly (the sample above might contain unwanted line breaks etc)?  
Make sure your indexing data does not contain any new lines...

--Alex

On Wed, Jun 5, 2013 at 7:16 PM, samCougars [sbaniya@gmail.com](mailto:sbaniya@gmail.com) wrote:

> All,
> 
> I'm hitting this url "[http://localhost:9200/\_bulk](http://localhost:9200/_bulk)" on my local  
> elasticSearch. Thru http PUT METHOD, I'm sending following JSON:  
> { "index" : { "\_index" : "dev1\_m1\_conference", "\_type" : "en\_exhibitor",  
> "\_id" : "1142" } }  
> {"name":"Exhibitor2","type":"Silver Sponsor","description":"exhibitor  
> description. exhibitor description. exhibitor description. exhibitor  
> description. exhibitor description. exhibitor description. exhibitor  
> description. exhibitor description. exhibitor
> 
> description.","nameSort":"Exhibitor2","typeSort":"SilverSponsor","website":null,"boothNameNum":"","published":"exhibitorPublished","206":"","205":"","cv":""}  
> { "index" : { "\_index" : "dev1\_m1\_conference", "\_type" : "en\_exhibitor",  
> "\_id" : "1143" } }  
> {"name":"Exhibitor3","type":"Gold Sponsor","description":"exhibitor  
> description. exhibitor description. exhibitor description. exhibitor  
> description. exhibitor description. exhibitor description. exhibitor  
> description. exhibitor description. exhibitor
> 
> description.","nameSort":"Exhibitor3","typeSort":"GoldSponsor","website":null,"boothNameNum":"","published":"exhibitorPublished","206":"","205":"","cv":""}
> 
> But, it seems like it is indexing ONLY first element of id = 1142. I know  
> this for sure because when I hit this URL  
> "[http://localhost:9200/dev1\_m1\_conference/en\_exhibitor/\_search](http://localhost:9200/dev1_m1_conference/en_exhibitor/_search)", it  
> returns  
> me the first element as a result.
> 
> Am I missing something while doing REST bulk indexing?
> 
> Thanks,
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Bulk-Indexing-via-REST-tp4036078.html](http://elasticsearch-users.115913.n3.nabble.com/Bulk-Indexing-via-REST-tp4036078.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![samCougars](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@samCougars](https://discuss.elastic.co/u/samCougars)
#### Post date: [June 6, 2013, 4:12pm UTC](https://discuss.elastic.co/t/bulk-indexing-via-rest/12285/3 "2013-06-06T16:12:58Z")

</div>

I tried a simple example w/ less string, but still the same problem. Here is a link to gist:

> <https://gist.github.com/anonymous/190bdf58531252a59629>

---

<div class="post-metadata">

### Author: ![samCougars](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@samCougars](https://discuss.elastic.co/u/samCougars)
#### Post date: [June 6, 2013, 8:09pm UTC](https://discuss.elastic.co/t/bulk-indexing-via-rest/12285/4 "2013-06-06T20:09:01Z")

</div>

I know my JSON string is correct because I tried this today:  
{ "delete" : { "\_index" : "dev1\_m1\_conference", "\_type" : "en\_exhibitor", "\_id" : "1142" } }  
{ "create" : { "\_index" : "dev1\_m1\_conference", "\_type" : "en\_exhibitor", "\_id" : "1142" } }  
{"name":"Exhibitor2","type":"Silver Sponsor"}  
{ "delete" : { "\_index" : "dev1\_m1\_conference", "\_type" : "en\_exhibitor", "\_id" : "1143" } }  
{ "create" : { "\_index" : "dev1\_m1\_conference", "\_type" : "en\_exhibitor", "\_id" : "1143" } }  
{"name":"Exhibitor3","type":"Gold Sponsor"}

and it indexed both 1143 and 1143. Deleting an index before creating can be costly when I'm indexing 100000 + records at a time. Any help is much appreciated...  
Thanks,  
Sam

---

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [June 7, 2013, 7:46am UTC](https://discuss.elastic.co/t/bulk-indexing-via-rest/12285/5 "2013-06-07T07:46:51Z")

</div>

You need a final line feed character, after the last JSON line.

Jörg

Am 06.06.2013 22:09, schrieb samCougars:

> Any help is much  
> appreciated...

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![samCougars](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@samCougars](https://discuss.elastic.co/u/samCougars)
#### Post date: [June 10, 2013, 11:31pm UTC](https://discuss.elastic.co/t/bulk-indexing-via-rest/12285/6 "2013-06-10T23:31:08Z")

</div>

I'm using \n (return character) after every index line. Can you explain more on "final line feed character"? Sample may be?

---

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [June 11, 2013, 6:57am UTC](https://discuss.elastic.co/t/bulk-indexing-via-rest/12285/7 "2013-06-11T06:57:41Z")

</div>

Then it should do fine. For clarity, I marked the line feeds in a  
comment [gist:190bdf58531252a59629 · GitHub](https://gist.github.com/anonymous/190bdf58531252a59629#comment-843392)  
The final line feed can not be left out.

Jörg

On Tuesday, June 11, 2013 1:31:08 AM UTC+2, Sam wrote:

> I'm using \n (return character) after every index line. Can you explain  
> more  
> on "final line feed character"? Sample may be?
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Bulk-Indexing-via-REST-tp4036078p4036330.html](http://elasticsearch-users.115913.n3.nabble.com/Bulk-Indexing-via-REST-tp4036078p4036330.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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: [July 6, 2017, 2:31am UTC](https://discuss.elastic.co/t/bulk-indexing-via-rest/12285/8 "2017-07-06T02:31:54Z")

</div>


