Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we do a bulk index without specifying a document ID for Elasticsearch?

Is it possible to do a bulk index without specifying a document ID? I want Elasticsearch to generate a random ID for me while indexing, but can it be done?

like image 263
Jonathan Moo Avatar asked Mar 14 '13 08:03

Jonathan Moo


People also ask

What is bulk in Elasticsearch?

Bulk: indexing multiple documentsedit Bulk requests allow sending multiple document-related operations to Elasticsearch in one request.

What is Elasticsearch Upsert?

Upserts are "Update or Insert" operations. This means an upsert attempts to run your update script, but if the document does not exist (or the field you are trying to update doesn't exist), default values are inserted instead.

What is Elasticsearch indexing?

In Elasticsearch, an index (plural: indices) contains a schema and can have one or more shards and replicas. An Elasticsearch index is divided into shards and each shard is an instance of a Lucene index. Indices are used to store the documents in dedicated data structures corresponding to the data type of fields.


1 Answers

Yes you can!

Tested on 0.90.0.Beta1:

$ cat requests 
{ "index" : { "_index" : "test", "_type" : "type1" } }
{ "field1" : "value1" }

$ curl -s -XPOST localhost:9200/_bulk --data-binary @requests; echo
{"took":6,"items":[{"create":{"_index":"test","_type":"type1","_id":"IWqsRqyhRVq-F69OLIngTA","_version":1,"ok":true}}]}
like image 173
dadoonet Avatar answered Sep 20 '22 19:09

dadoonet