新手问题 sunspot 配置问题,查询结果很难理解,请大家帮忙解决下吧

zhou1_zhen2 · 2014年01月03日 · 2240 次阅读

model 的配置正如:
searchable(:auto_index => true,:auto_remove => true) do #searchable do text :store_name, :stored => true text :title, :stored => true text :introduction, :stored => true text :brand_name, :stored => true text :grade_category, :stored => true text :grade_variety, :stored => true text :company_name, :stored => true text :commodity_name, :stored => true string :store_name string :brand_name string :grade_category boolean :state boolean :stick integer :store_id integer :company_id integer :brand_id, :stored => true integer :grade_id integer :sequence double :discount_price double :discount_rate double :original_price time :end_time

end

controller 操作如下: search_value = params[:query].nil? ? "" : (Message.rmmseg_cpp params[:query]) logger.info search_value price = params[:price].split("-") unless params[:price].nil? rate = params[:rate].split("-") unless params[:rate].nil? brand_id = Lexicon.where(:value => 1, :name => params[:brand]).first.id unless params[:brand].nil? @messages = Message.search do fulltext search_value with(:grade_category, params[:grade]) unless params[:grade].nil? #with(:brand_name, params[:brand]) unless params[:brand].nil? with(:brand_name,params[:brand]) unless params[:brand].nil? #with(:brand_id, brand_id) unless brand_id.nil? with(:store_name, params[:store]) unless params[:store].nil?

with(:state, true) with(:discount_price, price[0].to_d .. price[1].to_d) unless params[:price].nil? with(:discount_rate, rate[0].to_d*10 .. rate[1].to_d*10) unless params[:rate].nil? #with(:end_time).greater_than Time.now with(:end_time).greater_than_or_equal_to DateTime.now.strftime("%F").to_datetime order_by(:stick, :desc) order_by(:sequence, :desc) order_by(:discount_rate, :asc) order_by(:brand_name, :asc) order_by(:discount_price, :asc)

paginate :page => params[:page], :per_page => SALE_PER_PAGE end.results @search_text = params[:query]

功能操作日志

  1. 存在差异情况如下: 1.1.查询 A02 能正常显示,参数如下: [ path=select parameters={fq: ["type:Message", "brand_name_s:A02", "state_b:true", "end_time_d:[2014-01-03T00:00:00Z TO ]"], sort: "stick_b desc, sequence_i desc, discount_rate_e asc, brand_name_s asc, discount_price_e asc", start: 0, rows: 16, q: ":*"} ]

1.2.查询 HOTWIND 不能正常显示,参数如下: [ path=select parameters={fq: ["type:Message", "brand_name_s:HOTWIND", "state_b:true", "end_time_d:[2014-01-03T00:00:00Z TO ]"], sort: "stick_b desc, sequence_i desc, discount_rate_e asc, brand_name_s asc, discount_price_e asc", start: 0, rows: 16, q: ":*"} ]

2.全文搜索 A02 和 HOTWIND 都能正常显示,参数如下: 2.1 全文搜索 A02 [ path=select parameters={fq: ["type:Message", "state_b:true", "end_time_d:[2014-01-03T00:00:00Z TO ]"], sort: "stick_b desc, sequence_i desc, discount_rate_e asc, brand_name_s asc, discount_price_e asc", q: "A02", fl: " score", qf: "store_name_texts title_texts introduction_texts brand_name_texts grade_category_texts grade_variety_texts company_name_texts commodity_name_texts", defType: "edismax", start: 0, rows: 16} ]

2.2 全文搜索 HOTWIND [ path=select parameters={fq: ["type:Message", "state_b:true", "end_time_d:[2014-01-03T00:00:00Z TO ]"], sort: "stick_b desc, sequence_i desc, discount_rate_e asc, brand_name_s asc, discount_price_e asc", q: "HOTWIND", fl: " score", qf: "store_name_texts title_texts introduction_texts brand_name_texts grade_category_texts grade_variety_texts company_name_texts commodity_name_texts", defType: "edismax", start: 0, rows: 16} ]

期间也 reindex 或 stop,start 过,效果一样,配置了半天,可能还是 model 配置有问题,请大家帮忙分析下吧。如:怎么配置才能使 HOTWIND 也能正常显示出记录出来

通过http://localhost:8982/solr/#/development/queryquery测试,fq下brand_name_s:A02,A02就可以查出数据,fq下brand_name_s:HOTWIND,HOTWIND就查不出来。页面进行了

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请 注册新账号