Quirky behavior with _id source attribute


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: