Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想与各种Searchable模型记录进行一系列交互,并且在我的所有交互完成之前不重新索引任何模型。这可能吗?
Searchable
我知道我可以手动调用重新索引方法,但是如何手动指示 Sunspot不对给定的代码块重新索引?
Sunspot.session = Sunspot::Rails::StubSessionProxy.new(Sunspot.session) # whatever code you want to execute and not trigger a reindex Sunspot.session = Sunspot.session.original_session
参考:
链接1
链接2
johnnycakes 的回答很有帮助,但由于我需要完全阻止给定模型的自动索引,所以我使用了以下内容:
searchable :auto_index => false do text :name text :description # etc... end
这:auto_index => false部分是指示 Solr 不对模型编制索引的部分。直截了当 - 但由于某种原因,我花了一段时间才通过谷歌找到。
:auto_index => false