Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Attributes are not included in document payload when updating if names don't match #457

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:

https://github.com/elastic/elasticsearch-rails/blob/master/elasticsearch-model/lib/elasticsearch/model/indexing.rb#L391

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /