我已经为我的 rails 应用程序实现了 solr 搜索。我已经为搜索字段编制了索引,并且它运行良好。现在我想在搜索时排除一个名为 Title 的特定字段。如何在搜索时跳过这个特定字段。索引文本字段是否也有任何排除选项。
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
在这里,我如何才能从全文搜索中仅排除标题字段。
profiles = Profile.search do |s|
s.fulltext @selected_filters[:query][:value] , exclude => :title
end
有没有办法做到这一点?请帮忙
最佳答案
您可以指定要使用哪些字段 包括 在您的搜索中
Profile.search do
keywords @selected_filters[:query][:value], :fields => [:summary, :skills], :minimum_match => 1
end
关于ruby-on-rails - Sunspot/Solr 全文搜索 - 如何从全文搜索中排除某些字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10735926/