How to set _id in elasticsearch 2.0 How to set _id in elasticsearch 2.0 elasticsearch elasticsearch

How to set _id in elasticsearch 2.0


_id being deprecated simply means that you have to specify the id explicitly and ES won't offer you to parse your document a first time just to retrieve the field you've specified as the id field.

So all the current ways of indexing your documents are still valid as long as you specify the id explicitly:

curl -XPUT localhost:9200/index/type/your_id -d '{"field1": "value1"}'                                        ^                                        |                                 your id goes here

or in a bulk query

curl -XPOST localhost:9200/_bulk -d '{"index": {"_index": "index", "_type": "type", "_id": "your_id"}}{"field1": "value1"}                                     ^'                                                        |                                                 your id goes here