# Indexing via Bulk API

**URL:** <https://discuss.elastic.co/t/indexing-via-bulk-api/11658>\
**Category:** Elasticsearch\
**Created:** [April 22, 2013, 2:51pm UTC](https://discuss.elastic.co/t/indexing-via-bulk-api/11658 "2013-04-22T14:51:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashraf\_Sarhan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashraf_sarhan/32/2360_2.png) [@Ashraf\_Sarhan](https://discuss.elastic.co/u/Ashraf_Sarhan)\
**Post date:** [April 22, 2013, 2:51pm UTC](https://discuss.elastic.co/t/indexing-via-bulk-api/11658/1 "2013-04-22T14:51:42Z")

</div>

Hello, all

I'm using ES bulk API to index a doc and i have the following questions:

1. The doc contains more than one field, it's possible to indexing like the  
following:

{ "index" : { "\_index" : "test", "\_type" : "type1", "\_id" : "1" } }  
{ "field1" : "value1","field2" : "value2","field3" : "value3"}

OR it should look like the following:

{ "index" : { "\_index" : "test", "\_type" : "type1", "\_id" : "1" } }  
{ "field1" : "value1" }  
{ "field2" : "value2" }{ "field3" : "value3" }

1. It's a must to create the index first or if it does not exist, it will be created.

2. What happened if i rerun the indexer with the same doc to index.

Thanks,  
_Ashraf Sarhan_

--  
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:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 22, 2013, 3:00pm UTC](https://discuss.elastic.co/t/indexing-via-bulk-api/11658/2 "2013-04-22T15:00:06Z")

</div>

Answers inline

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 22 avr. 2013 à 16:51, Ashraf Sarhan [ashraf.sarhan@silicon-nile.com](mailto:ashraf.sarhan@silicon-nile.com) a écrit :

> Hello, all
> 
> I'm using ES bulk API to index a doc and i have the following questions:
> 
> 1. The doc contains more than one field, it's possible to indexing like the following:
> 
> { "index" : { "\_index" : "test", "\_type" : "type1", "\_id" : "1" } }  
> { "field1" : "value1","field2" : "value2","field3" : "value3"}

This is the way to go.

> OR it should look like the following:
> 
> { "index" : { "\_index" : "test", "\_type" : "type1", "\_id" : "1" } }  
> { "field1" : "value1" }  
> { "field2" : "value2" }  
> { "field3" : "value3" }

Won't work.

> 1. It's a must to create the index first or if it does not exist, it will be created.

I recommend to create the index first. You will also probably want to define mappings for your types and don't want to use defaults.

> 1. What happened if i rerun the indexer with the same doc to index.  
> It will be updated (\_version will be incremented BTW).

> Thanks,  
> Ashraf Sarhan
> 
> --  
> 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:40am UTC](https://discuss.elastic.co/t/indexing-via-bulk-api/11658/3 "2017-07-06T02:40:08Z")

</div>


