Sunspot / SOLR 未索引 STI 模型?
我在 Rails (2.3.11) 应用程序中有几个使用 STI 构建的模型,并按如下方式排列:
Gallery::Base
Gallery::Base < ActiveRecord::Base
(为 SOLR 建立索引)
Gallery::Local
Gallery::Base
(为 SOLR 建立索引)
Gallery::Remote
Gallery::Base
(未索引)
我发现有关这些模型的索引的不同结果。在我当前的开发数据库中,我有 77 个 Gallery::Local
对象,没有 Gallery::Remote
对象(这也意味着有 77 个 Gallery::Base
对象) code> 数据库中的对象)
问题是 Sunspot.search(Gallery::Base)
以及 Sunspot.search(Gallery::Local)
返回一个打。
现在,对于陌生的部分:在使用生产数据库的同事计算机上(具有数百个 Gallery::Local
对象),Sunspot.search(Gallery::Base) 没有返回任何命中)
或 Sunspot.search(Gallery::Local)
!
顺便说一句,我尝试在 Gallery::Base
和 Gallery::Local
上建立索引,并分别在每个索引中建立索引并重新索引,得到相同的结果。我还有许多其他索引模型,全文搜索可以按预期工作。
任何人都知道是什么原因造成的?
I have a couple of models in a Rails (2.3.11) application that are built using STI, and arranged as such:
Gallery::Base < ActiveRecord::Base
(indexed for SOLR)
Gallery::Local < Gallery::Base
(indexed for SOLR)
Gallery::Remote < Gallery::Base
(not indexed)
I am finding disparate results regarding the indexing of these models. In my current development database I have 77 Gallery::Local
objects and no Gallery::Remote
objects (which also means there are 77 Gallery::Base
objects in the db)
The problem is that either Sunspot.search(Gallery::Base)
as well as Sunspot.search(Gallery::Local)
returns a single hit.
Now for the stranger part: on a colleague's computer using the production database (with hundreds of Gallery::Local
objects), no hit whatsoever is returned from either Sunspot.search(Gallery::Base)
or Sunspot.search(Gallery::Local)
!
On a side note, I have tried having the index on both Gallery::Base
and Gallery::Local
, and in each one separately and reindexing, with the same results. I also have a number of other indexed models for which the full text search works as intended.
Anyone have any idea as what's causing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确实发现了问题所在。如果有人感兴趣,
sunspot:reindex
任务不会考虑命名空间和“模块”模型。查看 github 上的这个 pull request 以获取修复(转到差异部分)。
Actually found out what the problem was. If anyone's interested, the
sunspot:reindex
task does not contemplate namespaced and 'moduled' models.Check out this pull request on github for a fix (go to the Diff section).