Indexing via Bulk API

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.
For more options, visit https://groups.google.com/groups/opt_out.

Answers inline

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 22 avr. 2013 à 16:51, Ashraf Sarhan 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.
For more options, visit https://groups.google.com/groups/opt_out.