【发布时间】:2015-07-20 08:46:58
【问题描述】:
我在 ROR 中使用 sunspot-solr,在使用两个表创建可搜索块时需要帮助。(两个表的连接) 当索引形成时我想要执行的查询是:
SELECT a.id,a.title
FROM table_one a,table_two b
WHERE a.status=1
AND a.id=b.id
AND b.status=1
我希望“标题”字段是可搜索的(文本),只有当两个表中都存在 id 并且都具有状态 1 时。我希望它们被存储字段(没有 db 命中)。
class TableOne
has_many :table_twos
searchable do
text :title, :stored => true
string :status, :stored => true
string :id, :multiple => true, :stored => true do
table_twos.map(&:id)
end
end
当我搜索一个词时,我得到了 5 个结果。
但是当我从 table_two 中删除其中一个结果的条目并再次搜索相同的单词时.. 当我应该只得到另外 4 个时,我仍然得到 5 个结果。
有什么帮助吗?
【问题讨论】:
标签: ruby-on-rails solr sunspot-solr