在我的Rails应用程序中,我使用太阳黑子来索引几个不同的模型.然后我有一个全局搜索表单,返回混合结果.这很好用:
Sunspot.search(Person,EmailAddress,PhoneNumber,PhysicalAddress) do fulltext params[:q] paginate :per_page => 10 end
我想在此搜索中添加一个额外的模型,比如Project. 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字段添加搜索项目记录,而不是描述字段?
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。