4
Cross post from GitHub:轮胎/ ElasticSearch单表继承支持
我的应用程序寻找像美味,微博各种第三方服务的链接...我有以下的基类:
class Link
include Mongoid::Document
include Tire::Model::Search
include Tire::Model::Callbacks
field :href, type: String
field :name, type: String
mapping do
indexes :href, type: 'string', analyzer: 'url'
indexes :name, type: 'string', analyzer: 'keyword', boost: 10
end
end
和下面的类继承自Link
,并增加了两个字段:
class Link::Delicious < Link
field :tags, type: Array
field :time, type: Time
mapping do
indexes :tags, type: 'string', analyzer: 'keyword'
indexes :time, type: 'date'
end
end
搜索将通过基类来完成:Link.search('google.com')
。有没有机会得到这个工作?目前,Link::Delicious
中的(附加)字段被Tire/ElasticSearch完全忽略。