# Specifying id in document vs. url

**URL:** https://discuss.elastic.co/t/specifying-id-in-document-vs-url/5385
**Category:** Elasticsearch
**Created:** [September 14, 2011, 11:07pm UTC](https://discuss.elastic.co/t/specifying-id-in-document-vs-url/5385 "2011-09-14T23:07:38Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)
#### Post date: [September 14, 2011, 11:07pm UTC](https://discuss.elastic.co/t/specifying-id-in-document-vs-url/5385/1 "2011-09-14T23:07:38Z")

</div>

Is there a way to specify the id for the document being indexed in the json  
document itself? Maybe something like this:

curl -XPOST '[http://localhost:9200/es/test](http://localhost:9200/es/test)' -d  
'{"\_id":"1","user":"matt","message":"the id was given in the json  
document"}'

Thanks,  
Matt Weber

---

<div class="post-metadata">

### Author: ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)
#### Post date: [September 14, 2011, 11:31pm UTC](https://discuss.elastic.co/t/specifying-id-in-document-vs-url/5385/2 "2011-09-14T23:31:26Z")

</div>

Also wanted to specify that I would like to do this without using the bulk  
api. I am aware I can do this using the bulk api:

curl -XPOST '[http://localhost:9200/\_bulk](http://localhost:9200/_bulk)' -d '{"index": {"\_index" : "es",  
"\_type" : "test", "\_id" : "1"}}  
{"user":"matt","message":"id specified in bulk"}'

Thanks,  
Matt Weber

On Wed, Sep 14, 2011 at 4:07 PM, Matt Weber [matt@mattweber.org](mailto:matt@mattweber.org) wrote:

> Is there a way to specify the id for the document being indexed in the json  
> document itself? Maybe something like this:
> 
> curl -XPOST '[http://localhost:9200/es/test](http://localhost:9200/es/test)' -d  
> '{"\_id":"1","user":"matt","message":"the id was given in the json  
> document"}'
> 
> Thanks,  
> Matt Weber

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [September 15, 2011, 9:33am UTC](https://discuss.elastic.co/t/specifying-id-in-document-vs-url/5385/3 "2011-09-15T09:33:46Z")

</div>

You can't in 0.17, but, in master, you can by specifying a path for the id  
in the mapping. This will require another (fast, pull parsing, bailing once  
found) parse phase to extract the id (since it needs to be used for  
routing). So, in the simple case you can specify: \_id : {"path" : "\_id"} in  
the mapping.

On Thu, Sep 15, 2011 at 2:07 AM, Matt Weber [matt@mattweber.org](mailto:matt@mattweber.org) wrote:

> Is there a way to specify the id for the document being indexed in the json  
> document itself? Maybe something like this:
> 
> curl -XPOST '[http://localhost:9200/es/test](http://localhost:9200/es/test)' -d  
> '{"\_id":"1","user":"matt","message":"the id was given in the json  
> document"}'
> 
> Thanks,  
> Matt Weber

---

<div class="post-metadata">

### Author: ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)
#### Post date: [September 15, 2011, 3:02pm UTC](https://discuss.elastic.co/t/specifying-id-in-document-vs-url/5385/4 "2011-09-15T15:02:33Z")

</div>

Awesome, thanks! Is this going to make it into 0.17.7?

Thanks,  
Matt Weber

On Thu, Sep 15, 2011 at 2:33 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> You can't in 0.17, but, in master, you can by specifying a path for the id  
> in the mapping. This will require another (fast, pull parsing, bailing once  
> found) parse phase to extract the id (since it needs to be used for  
> routing). So, in the simple case you can specify: \_id : {"path" : "\_id"} in  
> the mapping.
> 
> On Thu, Sep 15, 2011 at 2:07 AM, Matt Weber [matt@mattweber.org](mailto:matt@mattweber.org) wrote:
> 
> > Is there a way to specify the id for the document being indexed in the  
> > json document itself? Maybe something like this:
> > 
> > curl -XPOST '[http://localhost:9200/es/test](http://localhost:9200/es/test)' -d  
> > '{"\_id":"1","user":"matt","message":"the id was given in the json  
> > document"}'
> > 
> > Thanks,  
> > Matt Weber

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [September 16, 2011, 6:47pm UTC](https://discuss.elastic.co/t/specifying-id-in-document-vs-url/5385/5 "2011-09-16T18:47:14Z")

</div>

No, it will only be in master.

On Thu, Sep 15, 2011 at 6:02 PM, Matt Weber [matt@mattweber.org](mailto:matt@mattweber.org) wrote:

> Awesome, thanks! Is this going to make it into 0.17.7?
> 
> Thanks,  
> Matt Weber
> 
> On Thu, Sep 15, 2011 at 2:33 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:
> 
> > You can't in 0.17, but, in master, you can by specifying a path for the id  
> > in the mapping. This will require another (fast, pull parsing, bailing once  
> > found) parse phase to extract the id (since it needs to be used for  
> > routing). So, in the simple case you can specify: \_id : {"path" : "\_id"} in  
> > the mapping.
> > 
> > On Thu, Sep 15, 2011 at 2:07 AM, Matt Weber [matt@mattweber.org](mailto:matt@mattweber.org) wrote:
> > 
> > > Is there a way to specify the id for the document being indexed in the  
> > > json document itself? Maybe something like this:
> > > 
> > > curl -XPOST '[http://localhost:9200/es/test](http://localhost:9200/es/test)' -d  
> > > '{"\_id":"1","user":"matt","message":"the id was given in the json  
> > > document"}'
> > > 
> > > Thanks,  
> > > Matt Weber

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [September 16, 2011, 6:47pm UTC](https://discuss.elastic.co/t/specifying-id-in-document-vs-url/5385/6 "2011-09-16T18:47:28Z")

</div>

Sorry, its currently in master, will be part of 0.18 (no release date yet).

On Fri, Sep 16, 2011 at 9:47 PM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> No, it will only be in master.
> 
> On Thu, Sep 15, 2011 at 6:02 PM, Matt Weber [matt@mattweber.org](mailto:matt@mattweber.org) wrote:
> 
> > Awesome, thanks! Is this going to make it into 0.17.7?
> > 
> > Thanks,  
> > Matt Weber
> > 
> > On Thu, Sep 15, 2011 at 2:33 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:
> > 
> > > You can't in 0.17, but, in master, you can by specifying a path for the  
> > > id in the mapping. This will require another (fast, pull parsing, bailing  
> > > once found) parse phase to extract the id (since it needs to be used for  
> > > routing). So, in the simple case you can specify: \_id : {"path" : "\_id"} in  
> > > the mapping.
> > > 
> > > On Thu, Sep 15, 2011 at 2:07 AM, Matt Weber [matt@mattweber.org](mailto:matt@mattweber.org) wrote:
> > > 
> > > > Is there a way to specify the id for the document being indexed in the  
> > > > json document itself? Maybe something like this:
> > > > 
> > > > curl -XPOST '[http://localhost:9200/es/test](http://localhost:9200/es/test)' -d  
> > > > '{"\_id":"1","user":"matt","message":"the id was given in the json  
> > > > document"}'
> > > > 
> > > > Thanks,  
> > > > Matt Weber

---

<div class="post-metadata">

### Author: ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)
#### Post date: [September 16, 2011, 8:56pm UTC](https://discuss.elastic.co/t/specifying-id-in-document-vs-url/5385/7 "2011-09-16T20:56:17Z")

</div>

Sounds good, thanks!

Thanks,  
Matt Weber

On Fri, Sep 16, 2011 at 11:47 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> Sorry, its currently in master, will be part of 0.18 (no release date yet).
> 
> On Fri, Sep 16, 2011 at 9:47 PM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:
> 
> > No, it will only be in master.
> > 
> > On Thu, Sep 15, 2011 at 6:02 PM, Matt Weber [matt@mattweber.org](mailto:matt@mattweber.org) wrote:
> > 
> > > Awesome, thanks! Is this going to make it into 0.17.7?
> > > 
> > > Thanks,  
> > > Matt Weber
> > > 
> > > On Thu, Sep 15, 2011 at 2:33 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:
> > > 
> > > > You can't in 0.17, but, in master, you can by specifying a path for the  
> > > > id in the mapping. This will require another (fast, pull parsing, bailing  
> > > > once found) parse phase to extract the id (since it needs to be used for  
> > > > routing). So, in the simple case you can specify: \_id : {"path" : "\_id"} in  
> > > > the mapping.
> > > > 
> > > > On Thu, Sep 15, 2011 at 2:07 AM, Matt Weber [matt@mattweber.org](mailto:matt@mattweber.org) wrote:
> > > > 
> > > > > Is there a way to specify the id for the document being indexed in the  
> > > > > json document itself? Maybe something like this:
> > > > > 
> > > > > curl -XPOST '[http://localhost:9200/es/test](http://localhost:9200/es/test)' -d  
> > > > > '{"\_id":"1","user":"matt","message":"the id was given in the json  
> > > > > document"}'
> > > > > 
> > > > > Thanks,  
> > > > > Matt Weber

---

<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, 3:54am UTC](https://discuss.elastic.co/t/specifying-id-in-document-vs-url/5385/8 "2017-07-06T03:54:14Z")

</div>


