简体   繁体   中英

Remove Sunspot's fq parameter from Solr query

I am using Sunspot for Rails, and I would like to remove the filter query from the Sunspot-generated Solr parameter (seen as fq: ["type:Job"] ):

Current :

SOLR Request [ path=select parameters={fq: ["type:Job"], q: "programmer", fl: "* score", qf: "Title", defType: "edismax", start: 0, rows: 30} ]

Desired :

SOLR Request [ path=select parameters={q: "programmer", fl: "* score", qf: "Title", defType: "edismax", start: 0, rows: 30} ]

My model:

class Job < ActiveRecord::Base
  searchable do
    text :Title, :as => :Title
  end

I've read the "manually adjusting Solr parameters" from the docs, but couldn't find any reference to actually removing the fq parameter. Thanks!

Can't you just use

Job.search do
 adjust_solr_params do |params|
   params.except! :fq
 end
end

Or something similiar in order to remove the :fq key from the params hash

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM