When you use :model wrapper, and it loads object attributes from ES to Mongoid model, it sets your association's id as {"$oid" => BSON::ObjectId()}, where it should just be BSON::ObjectId().
So when you call your relation,you'll get an exception:
my_object.my_relation
"invalid operator: $oid"
I think it's more Mongoid problem:
when you dump BSON::ObjectId you get {"$oid" => "abc012345"}, and you can not load it back as BSON::ObjectID using JSON.parse.
So we should do some workarounds, for example check if restored object is a hash with $oid and then intitalize BSON::ObjectId object for it.
When you use :model wrapper, and it loads object attributes from ES to Mongoid model, it sets your association's id as {"$oid" => BSON::ObjectId()}, where it should just be BSON::ObjectId().
So when you call your relation,you'll get an exception:
I think it's more Mongoid problem: when you dump BSON::ObjectId you get {"$oid" => "abc012345"}, and you can not load it back as BSON::ObjectID using JSON.parse. So we should do some workarounds, for example check if restored object is a hash with $oid and then intitalize BSON::ObjectId object for it.
Some related info https://github.com/mongoid/mongoid/pull/2947