Rails Sunspot/Solr: Ordering on multiple-value field

牧云@^-^@ 提交于 2019-12-10 17:16:02

问题


I'm trying to do a priority "order by" on a multiple-value field using solr - any idea how I can accomplish the below?

searchable do
  integer :skill_ids, :multiple => true
end

def self.filter_using_solr(opts={})
  Sunspot.search(JobApplication) do |s|
    opts[:order_skill_ids].each do |skill_id|
        s.order_by(:skill_ids, skill_id)
      end
    end
  end
end

I get the following exception "skill_ids cannot be used for ordering because it is a multiple-value field" - but not sure on the alternate path.


回答1:


Perhaps what you're looking for is Solr's faceted search.

There are several posts on this subject including How do I set up a facet search with a many to many relationship using Sunspot?

Naturally, the Solr docs are also useful.



来源:https://stackoverflow.com/questions/8188456/rails-sunspot-solr-ordering-on-multiple-value-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!