0
因此,在我添加分組選項以濾除重複結果之前,我的搜索工作正常,即使我按照sunspot api的指示進行了所有操作。現在我一直在搜索空白頁面,即使我搜索現有的記錄。添加分組後,Rails太陽黑子結果消失
attached_vehicle.rb
class AttachedVehicle < ActiveRecord::Base
belongs_to :diy
searchable do
text :make
text :model
text :attached_vehicles_year do
(self.start_year..self.end_year).to_a
end
string(:diy_id_str) { |p| p.diy_id.to_s }
end
end
attached_vehicles_controller.rb
def select_search
@select_search = AttachedVehicle.search do
keywords(params[:attached_vehicles_model])
keywords(params[:attached_vehicles_year])
keywords(Make.find(params[:attached_vehicles_make]).make_name)
group :diy_id_str
end
end
這裏是我得到SOLR請求控制檯提交搜索
SOLR Request (13.0ms) [ path=select parameters={fq: ["type:AttachedVehicle"], q: "(_query_:"{!edismax qf='make_text model_text attached_vehicles_year_text'}A6" AND _query_:"{!edismax qf='make_text model_text attached_vehicles_year_text'}2005" AND _query_:"{!edismax qf='make_text model_text attached_vehicles_year_text'}AUDI")", fl: "* score", start: 0, rows: 30, group: "true", group.ngroups: "true", group.field: ["diy_id_str_s"]} ]
後
---------------------------------------------- -------------------------------------------------- ------------------------------------ EDIT
我發現「group:diy_id_str 「在控制器中的行導致這個問題,當我刪除它時,一切正常,但只要我加回來,我沒有得到任何結果。但在太陽黑子控制檯它顯示我得到點擊,如這裏看到的
2086072 INFO (qtp20557198-14) [ x:development] o.a.s.c.S.Request [development] webapp=/solr path=/select params={q=AUDI&defType=edismax&qf=make_text+model_text+attached_vehicles_year_text&fl=*+score&start=0&fq=type:AttachedVehicle&rows=30&group.ngroups=true&wt=ruby&group.field=diy_id_str_s&group=true} hits=2 status=0 QTime=3