I am using elastic search in a rails app. I have a model - Posts which and I want to add the tags attribute to my index. The problem is tags are a list of mongoid object id's. So I want to convert them to their string values.
class Post
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
field :title, :type => String
field :tags, :type => Array, :default => []
def as_indexed_json(options = {})
self.as_json({
only: [:title, :body, :tags => ['string', 'string', 'string']]
})
end
end
Basically i want to convert [id1, id2, id3] => [string1, string2, string3] and index on that