# Quirky behavior with \_id source attribute

**URL:** <https://discuss.elastic.co/t/quirky-behavior-with--id-source-attribute/10137>\
**Category:** Elasticsearch\
**Created:** [December 20, 2012, 8:39pm UTC](https://discuss.elastic.co/t/quirky-behavior-with--id-source-attribute/10137 "2012-12-20T20:39:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brad\_L](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Brad\_L](https://discuss.elastic.co/u/Brad_L)\
**Post date:** [December 20, 2012, 8:39pm UTC](https://discuss.elastic.co/t/quirky-behavior-with--id-source-attribute/10137/1 "2012-12-20T20:39:05Z")

</div>

hello!

i have a prototype of an app where i am synchonizing state between  
mongo and elastic search. our code is written in java and we are using  
morphia as an ORM. for simplicity, i am indexing the entire mongo  
DBObject (id and all) into the elasticsearch source attribute and have  
run into cases where mongo queries suddenly stop working correctly.  
blanket searches return all documents but keyword searches fail to  
return any results.

i spent some quality time with my debugger and found that  
elasticsearch wont tolerate a complex \_id source property (such as  
{ "\_id" : { "$oid" : "12345"}) _IF_ \_id is the first attribute in the  
source document. If you relocate \_id to appear later in the source  
payload, it works fine. Here's a gist showing the phenomenon:

> <https://gist.github.com/anonymous/4348293>

--

---

<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:59am UTC](https://discuss.elastic.co/t/quirky-behavior-with--id-source-attribute/10137/2 "2017-07-06T02:59:02Z")

</div>

Closed on July 6, 2017, 2:59am UTC


