-
Couldn't load subscription status.
- Fork 808
Closed
Labels
@romeroadrian
Description
Attributes are not included in document payload when updating if names don't match.
This is a common scenario, i.e. your model has latitude and longitude attributes where your elasticsearch mapping has a location field.
def as_indexed_json(opts={})
{location: {latitude: self.latitude, longitude: self.longitude}}
end
In this case, if latitude or longitude change the location field won't be included in the payload (since names don't match).
Relevant code:
attributes = if respond_to?(:as_indexed_json)
self.as_indexed_json.select { |k,v| changed_attributes.keys.map(&:to_s).include? k.to_s }
else
changed_attributes
end