# How to include the \_id field in the \_source

**URL:** <https://discuss.elastic.co/t/how-to-include-the--id-field-in-the--source/13319>\
**Category:** Elasticsearch\
**Created:** [August 24, 2013, 3:32pm UTC](https://discuss.elastic.co/t/how-to-include-the--id-field-in-the--source/13319 "2013-08-24T15:32:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Liron\_Cohen](https://avatars.discourse-cdn.com/v4/letter/l/65b543/32.png) [@Liron\_Cohen](https://discuss.elastic.co/u/Liron_Cohen)\
**Post date:** [August 24, 2013, 3:32pm UTC](https://discuss.elastic.co/t/how-to-include-the--id-field-in-the--source/13319/1 "2013-08-24T15:32:13Z")

</div>

Hello,

My projects uses CouchDB and thus each document contains a _\_id_ fields  
that is uses for couch.  
Usually the value for the \_id is the [type + dash + number]. e.g  
"Location-7".  
I also have (in each document) and _Id_ field which holds the integer  
value. e.g 7.  
In ES I don't need the long string \_id used for couch, so I defined (I'm  
using NEST):  
IdProperty = "id"  
And so, my documents are stored like this: _/index/Locations/7_ instead of \*  
/index/Locations/Location-7\*  
The problem is that ES disregards the _\_id_ field all together.

Is there a way to tell ES to serialize the _\_id_ field as if it was any  
other field?

Thanks.  
Liron

--  
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:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [August 24, 2013, 6:12pm UTC](https://discuss.elastic.co/t/how-to-include-the--id-field-in-the--source/13319/2 "2013-08-24T18:12:01Z")

</div>

You can use any field as the ID by using using the path option:  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/id-field/) You can also  
change the analyzer if you want, or just leave the field as not analyzed  
(ideally).

Not sure what you mean by "And so, my documents are stored like this:  
/index/Locations/7 instead of /index/Locations/Location-7". Fields are  
stored, not documents.

Cheers,

Ivan

On Sat, Aug 24, 2013 at 8:32 AM, Liron Cohen [cliron1@gmail.com](mailto:cliron1@gmail.com) wrote:

> Hello,
> 
> My projects uses CouchDB and thus each document contains a _\_id_ fields  
> that is uses for couch.  
> Usually the value for the \_id is the [type + dash + number]. e.g  
> "Location-7".  
> I also have (in each document) and _Id_ field which holds the integer  
> value. e.g 7.  
> In ES I don't need the long string \_id used for couch, so I defined (I'm  
> using NEST):  
> IdProperty = "id"  
> And so, my documents are stored like this: _/index/Locations/7_ instead  
> of _/index/Locations/Location-7_  
> The problem is that ES disregards the _\_id_ field all together.
> 
> Is there a way to tell ES to serialize the _\_id_ field as if it was any  
> other field?
> 
> Thanks.  
> Liron
> 
> --  
> 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).

--  
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:19am UTC](https://discuss.elastic.co/t/how-to-include-the--id-field-in-the--source/13319/3 "2017-07-06T02:19:53Z")

</div>


