Skip to content

update_document doesn't work on derived fields #195

@irsalmashhor

Description

@irsalmashhor

Hi,

This is similar to issue #140

If I have the following model defined

 class Article < ActiveRecord::Base
  include Elasticsearch::Model

  def as_indexed_json(options = {})
    { description: self.description }
    { short_description: self.description[0...100] }
  end
end

Calling update_document will not update the short_description field because in the update_document method here:

self.as_indexed_json.select { |k,v| changed_attributes.keys.map(&:to_s).include? k.to_s }

It will only select attributes that are defined in the model

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions