# Using MongoDB IDs as ES document IDs

**URL:** <https://discuss.elastic.co/t/using-mongodb-ids-as-es-document-ids/8157>\
**Category:** Elasticsearch\
**Created:** [June 19, 2012, 4:53pm UTC](https://discuss.elastic.co/t/using-mongodb-ids-as-es-document-ids/8157 "2012-06-19T16:53:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Carr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james_carr/32/956_2.png) [@James\_Carr](https://discuss.elastic.co/u/James_Carr)\
**Post date:** [June 19, 2012, 4:53pm UTC](https://discuss.elastic.co/t/using-mongodb-ids-as-es-document-ids/8157/1 "2012-06-19T16:53:00Z")

</div>

Hi All,

I recently have been working on a Mongoose plugin to index MongoDB  
documents in Elasticsearch and wanted to use the same IDs across both but  
ran into some errors. I'll be able to investigate further when I get home  
as I don't recall the exact error but I am wondering if anyone has  
experienced this?

For now I just store the MongoDB id as \_mongoId in the elastic search  
document.

Thanks,  
James

---

<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:** [June 21, 2012, 7:51am UTC](https://discuss.elastic.co/t/using-mongodb-ids-as-es-document-ids/8157/2 "2012-06-21T07:51:49Z")

</div>

You should be able to simply store the mongo id it as a string...

On Tue, Jun 19, 2012 at 6:53 PM, James Carr [james.r.carr@gmail.com](mailto:james.r.carr@gmail.com) wrote:

> Hi All,
> 
> I recently have been working on a Mongoose plugin to index MongoDB  
> documents in Elasticsearch and wanted to use the same IDs across both but  
> ran into some errors. I'll be able to investigate further when I get home  
> as I don't recall the exact error but I am wondering if anyone has  
> experienced this?
> 
> For now I just store the MongoDB id as \_mongoId in the Elasticsearch  
> document.
> 
> Thanks,  
> James

---

<div class="post-metadata">

**Author:** ![benny\_sadeh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benny_sadeh/32/2797_2.png) [@benny\_sadeh](https://discuss.elastic.co/u/benny_sadeh)\
**Post date:** [June 22, 2012, 4:11am UTC](https://discuss.elastic.co/t/using-mongodb-ids-as-es-document-ids/8157/3 "2012-06-22T04:11:01Z")

</div>

doing the very same thing and haven't bumped into any problems.  
can you be more specific about what sort of problems are you running into?

On Tuesday, June 19, 2012 9:53:00 AM UTC-7, James Carr wrote:

> Hi All,
> 
> I recently have been working on a Mongoose plugin to index MongoDB  
> documents in Elasticsearch and wanted to use the same IDs across both but  
> ran into some errors. I'll be able to investigate further when I get home  
> as I don't recall the exact error but I am wondering if anyone has  
> experienced this?
> 
> For now I just store the MongoDB id as \_mongoId in the Elasticsearch  
> document.
> 
> Thanks,  
> James

---

<div class="post-metadata">

**Author:** ![James\_Carr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james_carr/32/956_2.png) [@James\_Carr](https://discuss.elastic.co/u/James_Carr)\
**Post date:** [June 22, 2012, 4:25am UTC](https://discuss.elastic.co/t/using-mongodb-ids-as-es-document-ids/8157/4 "2012-06-22T04:25:21Z")

</div>

To quote what has probably been said may times on the internet, "I was  
doing it wrong." 🙂

Thanks,  
James

On Thu, Jun 21, 2012 at 11:11 PM, benny.sadeh [benny.sadeh@gmail.com](mailto:benny.sadeh@gmail.com) wrote:

> doing the very same thing and haven't bumped into any problems.  
> can you be more specific about what sort of problems are you running into?
> 
> On Tuesday, June 19, 2012 9:53:00 AM UTC-7, James Carr wrote:
> 
> > Hi All,
> > 
> > I recently have been working on a Mongoose plugin to index MongoDB  
> > documents in Elasticsearch and wanted to use the same IDs across both but  
> > ran into some errors. I'll be able to investigate further when I get home  
> > as I don't recall the exact error but I am wondering if anyone has  
> > experienced this?
> > 
> > For now I just store the MongoDB id as \_mongoId in the Elasticsearch  
> > document.
> > 
> > Thanks,  
> > James

---

<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:22am UTC](https://discuss.elastic.co/t/using-mongodb-ids-as-es-document-ids/8157/5 "2017-07-06T03:22:58Z")

</div>


