我正在使用
elasticsearch-rails和
mongoid
我有以下简单的字段映射:
我有以下简单的字段映射:
"title": { "type": "string","fields": { "raw": { "type": "string","index": "not_analyzed" } } }
我的模型看起来像这样:
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
任何人都可以举例说明如何使用title.raw字段定义rails模型,以及如何访问该字段?由于多字段已被弃用,因此很难找到使用rails和mongoid的工作示例.
谢谢
解决方法
您应该能够在模型中使用以下属性定义来实现此目的:
attribute :title,String,mapping: { fields: { raw: { type: 'string',index: 'not_analyzed' } } }
原文地址:https://www.jb51.cc/ruby/270083.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。