问题
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