在我的 Rails 应用程序中,我使用 Sunspot 来索引几个不同的模型。然后我有一个返回混合结果的全局搜索表单。这工作正常:
Sunspot.search(Person, EmailAddress, PhoneNumber, PhysicalAddress) do
fulltext params[:q]
paginate :per_page => 10
end
我想在这个搜索中添加一个额外的模型,比如 Project。项目模型有相当多的索引:
class Project < ActiveRecord::Base
searchable do
string :category do
category.name.downcase if category = self.category
end
string :client do
client.name.downcase if client = self.client
end
string :status
text :tracking_number
text :description
integer :category_id, :references => Category
integer :client_id, :references => Client
integer :tag_ids, :multiple => true, :references => Tag
time :created_at, :trie => true
time :updated_at, :trie => true
time :received_at, :trie => true
time :completed_at, :trie => true
end
end
如何修改我的原始Sunspot.search
调用以仅通过tracking_number
字段而不是字段添加对项目记录的搜索description
?