When using the wrapper :model option for ealsticsearch results, the response object trys to assign elastics '_source' node as attributes/fields of the new model instance base on the _type field, but because the model does not respond to _type, _source, _score, or _highlight fields it rescues the error and then assigns those fields to model and then returns the model. This causes the object to initialize twice.
Would it be better to check if the model responds to the elasticsearch fields, and if not assign them to the model if their values are not nil? It seems like this would be a better instantiating the model twice.
When using the wrapper :model option for ealsticsearch results, the response object trys to assign elastics '_source' node as attributes/fields of the new model instance base on the _type field, but because the model does not respond to _type, _source, _score, or _highlight fields it rescues the error and then assigns those fields to model and then returns the model. This causes the object to initialize twice.
lib/mongoid/elasticsearch/response.rb:175:in 'new' lib/mongoid/elasticsearch/response.rb:185:in 'new'
Would it be better to check if the model responds to the elasticsearch fields, and if not assign them to the model if their values are not nil? It seems like this would be a better instantiating the model twice.
If it makes sense I'll fork and fix. :)