# Doubt regarding bulk api in elasticsearch

**URL:** <https://discuss.elastic.co/t/doubt-regarding-bulk-api-in-elasticsearch/56997>\
**Category:** Elasticsearch\
**Created:** [August 2, 2016, 11:17am UTC](https://discuss.elastic.co/t/doubt-regarding-bulk-api-in-elasticsearch/56997 "2016-08-02T11:17:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kamaljit\_Pati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kamaljit_pati/32/13731_2.png) [@Kamaljit\_Pati](https://discuss.elastic.co/u/Kamaljit_Pati)\
**Post date:** [August 2, 2016, 11:17am UTC](https://discuss.elastic.co/t/doubt-regarding-bulk-api-in-elasticsearch/56997/1 "2016-08-02T11:17:13Z")

</div>

My requirement is that i want to create index with bulk data in c program without using file, because you know it involves reading from disk also which will make my program slow. So without using file, can i store multiple datas in json format in string and in one shot add the datas to an index or is there any way to do that. I already checked that either we will put the data after **-d'{** and by entering one by one we can put the datas, but is there any way like using newline character it will accept the whole dataset in one shot. Please reply me if you find anything regarding this.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 2, 2016, 9:43pm UTC](https://discuss.elastic.co/t/doubt-regarding-bulk-api-in-elasticsearch/56997/2 "2016-08-02T21:43:34Z")

</div>

Have you seen [https://www.elastic.co/guide/en/elasticsearch/reference/2.3/docs-bulk.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/docs-bulk.html)

---

<div class="post-metadata">

**Author:** ![Kamaljit\_Pati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kamaljit_pati/32/13731_2.png) [@Kamaljit\_Pati](https://discuss.elastic.co/u/Kamaljit_Pati)\
**Post date:** [August 4, 2016, 9:55am UTC](https://discuss.elastic.co/t/doubt-regarding-bulk-api-in-elasticsearch/56997/3 "2016-08-04T09:55:38Z")

</div>

Already saw the link and tried with"\n" option in bulk api in c. But its not working. Can you show me one example where how i can use this api to create index and enter multiple data in one shot without using file. It should read data from a string or structure or somethingline this. In all the places i saw they are using json file to enter bulk datas.

But i need how do i store multiple datas in a data structure and and push them to elasticsearch in one shot at some point of time.

---

<div class="post-metadata">

**Author:** ![Kamaljit\_Pati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kamaljit_pati/32/13731_2.png) [@Kamaljit\_Pati](https://discuss.elastic.co/u/Kamaljit_Pati)\
**Post date:** [August 19, 2016, 6:27am UTC](https://discuss.elastic.co/t/doubt-regarding-bulk-api-in-elasticsearch/56997/4 "2016-08-19T06:27:07Z")

</div>

Any updates guys....about bulk API in C program without using file.

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [August 19, 2016, 8:52am UTC](https://discuss.elastic.co/t/doubt-regarding-bulk-api-in-elasticsearch/56997/5 "2016-08-19T08:52:40Z")

</div>

You do not need a file, just pass the bulk requests in the body of your request:

```auto
$ curl -XPOST localhost:9200/_bulk -d '
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{ "field1" : "value1" }
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }
{ "field1" : "value2" }
'

```

---

<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 5, 2017, 10:26pm UTC](https://discuss.elastic.co/t/doubt-regarding-bulk-api-in-elasticsearch/56997/6 "2017-07-05T22:26:43Z")

</div>


