Rails Sunspot / Solr: ordering in a multi-valued field

I am trying to prioritize "sort by" in a multi-value field using solr - any idea how can I follow 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 field with multiple values," but not sure about the alternative path.

+4
source share
1 answer

You may be looking for a solr faceted search .

There are several posts on this subject, including How do I customize facet searches using many to many relationships using Sunspot?

Naturally, Soldocs are also useful.

+3
source

Source: https://habr.com/ru/post/1381961/


All Articles