【发布时间】:2018-11-19 13:13:51
【问题描述】:
我想根据任何文本字段提升结果中的文档。
例如。考虑以下模式
class Post < ActiveRecord::Base
searchable do
text :title, :body
text :comments do
comments.map { |comment| comment.body }
end
text :tags
boolean :featured
end
end
要提升布尔字段,我们可以像这样简单地添加一个 boost 子句:
Post.search do
fulltext '*:*' do
boost(2.0){with(:featured, true)}
end
end
我想在文本字段上实现提升,假设我想获取所有帖子,但标记为“重要”的帖子必须先出现,如下所示:
Post.search do
fulltext '*:*' do
boost(2.0){fulltext 'important', fields: :tags}
end
end
我知道上面的代码不正确,但解释了所需的行为。
【问题讨论】:
标签: ruby-on-rails solr sunspot sunspot-solr solr-boost