I use elasticsearch-rails and mongoid . I have the following simple field mapping:
"title": { "type": "string", "fields": { "raw": { "type": "string", "index": "not_analyzed" } } }
My model looks like this:
class ArticlesEvent include Mongoid::Document include Elasticsearch::Model field :title, type: String attr_accessible :title def as_indexed_json(options={}) as_json(except: [:id, :_id]) end
Can someone show an example of how to define a rail model with a title.raw field and how to access this field? Since multi-field fields are outdated, it is difficult to find a working example with rails and mangoids.
thanks
ruby-on-rails mongoid elasticsearch
Orr
source share