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