# Bulk upsert with \_id path rather than explicit \_id

**URL:** <https://discuss.elastic.co/t/bulk-upsert-with--id-path-rather-than-explicit--id/13200>\
**Category:** Elasticsearch\
**Created:** [August 13, 2013, 1:55pm UTC](https://discuss.elastic.co/t/bulk-upsert-with--id-path-rather-than-explicit--id/13200 "2013-08-13T13:55:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Val\_Vakar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val_vakar/32/2017_2.png) [@Val\_Vakar](https://discuss.elastic.co/u/Val_Vakar)\
**Post date:** [August 13, 2013, 1:55pm UTC](https://discuss.elastic.co/t/bulk-upsert-with--id-path-rather-than-explicit--id/13200/1 "2013-08-13T13:55:35Z")

</div>

Hello experts,

I'm trying to do a bulk upsert with an \_id path on ES 0.90.3. This saves  
me the need to explicitly state the \_id at upsert time. However, I can't  
seem to get it working and I'm sure I'm doing something silly.  
Any help would be greatly appreciated

Thanks!  
-Val

curl -XPOST [http://localhost:9200/val123](http://localhost:9200/val123) -d {}  
echo "Should be fine"  
curl -XPOST [http://localhost:9200/val123/tweet/\_mapping](http://localhost:9200/val123/tweet/_mapping) -d '{ "tweet" : {  
"\_id" : { "path" : "post\_id" } } }'  
echo "Should be fine"

curl -XPOST [http://localhost:9200/val123/tweet/\_bulk](http://localhost:9200/val123/tweet/_bulk) -d '  
{"update":{}}  
{"doc": {"message" : "You know, for Search", "post\_id" : "123"},  
"doc\_as\_upsert": true}  
'  
echo 'Should throw error:  
{"error":"ActionRequestValidationException[Validation Failed: 1: id is  
missing;]","status":500}'

--  
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:** [August 13, 2013, 2:36pm UTC](https://discuss.elastic.co/t/bulk-upsert-with--id-path-rather-than-explicit--id/13200/2 "2013-08-13T14:36:20Z")

</div>

Yeah. Bulk process does not read document content but only headers and then pass content (index/update/delete request) to the right shard.  
To extract the right shard, we need to know the \_id without parsing the body itself.

I'm afraid you must provide it.

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

Le 13 août 2013 à 15:55, Val Vakar [val.vakar@gmail.com](mailto:val.vakar@gmail.com) a écrit :

> Hello experts,
> 
> I'm trying to do a bulk upsert with an \_id path on ES 0.90.3. This saves me the need to explicitly state the \_id at upsert time. However, I can't seem to get it working and I'm sure I'm doing something silly.  
> Any help would be greatly appreciated
> 
> Thanks!  
> -Val
> 
> curl -XPOST [http://localhost:9200/val123](http://localhost:9200/val123) -d {}  
> echo "Should be fine"  
> curl -XPOST [http://localhost:9200/val123/tweet/\_mapping](http://localhost:9200/val123/tweet/_mapping) -d '{ "tweet" : { "\_id" : { "path" : "post\_id" } } }'  
> echo "Should be fine"
> 
> curl -XPOST [http://localhost:9200/val123/tweet/\_bulk](http://localhost:9200/val123/tweet/_bulk) -d '  
> {"update":{}}  
> {"doc": {"message" : "You know, for Search", "post\_id" : "123"}, "doc\_as\_upsert": true}  
> '  
> echo 'Should throw error: {"error":"ActionRequestValidationException[Validation Failed: 1: id is missing;]","status":500}'
> 
> --  
> 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:21am UTC](https://discuss.elastic.co/t/bulk-upsert-with--id-path-rather-than-explicit--id/13200/3 "2017-07-06T02:21:19Z")

</div>


