I'm using elasticsearch-rails and mongoid I have the following simple mapping with fields:
"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 anyone show an example how to define the rails model with the title.raw field, and how to access that field? Since the multi fields have been deprecated it's hard to find a working example with rails and mongoid.
Thanks
multi-fieldtype, which can now simply be astringtype with an embeddedfieldsstructure, i.e. exactly what you have above.