简体   繁体   中英

Sunspot / Solr Full text search - how to exclude certain fields from full text search?

I have implemented solr search for my rails application. I have indexed the fields for search and it is working perfectly. Now i want to exclude one particular field named Title while searching.How can i skip this particular field while searching. Is there any exclude options for the indexed text fields also.

searchable  do

  integer :id
  boolean :searchable
  boolean :premium
  string  :status
  time    :updated_at
  time    :created_at

  ###################################################
  # Fulltext search fields

  text :title

  text :summary 
  text :skills

end

Here how can i exclude only the Title field from the Fulltext search.like

 profiles = Profile.search do |s|
   s.fulltext @selected_filters[:query][:value] , exclude => :title
end

Is there any way to do like this? please help

You can specify which fields to include in your search

Profile.search do
  keywords @selected_filters[:query][:value], :fields => [:summary, :skills], :minimum_match => 1
end

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