【发布时间】:2011-11-19 13:46:54
【问题描述】:
有什么方法可以跳过将 ActiveRecord::Base 的 default_scope 应用到 Thinking Sphinx 的搜索结果?
【问题讨论】:
标签: ruby-on-rails activerecord thinking-sphinx
有什么方法可以跳过将 ActiveRecord::Base 的 default_scope 应用到 Thinking Sphinx 的搜索结果?
【问题讨论】:
标签: ruby-on-rails activerecord thinking-sphinx
在调用搜索之前使用unscoped方法即可。
查看更多info
编辑
见https://github.com/freelancing-god/thinking-sphinx/blob/master/lib/thinking_sphinx/search.rb#L89。添加和选项 :ignore_default 以跳过范围。 (但这使用了 Sphinx 范围,因此需要检查)。
【讨论】:
Article.unscoped.search(...)和Article.unscoped {Article.search(...)},都返回了作用域结果
Article.search(keywords, :ignore_default => true) 返回范围内的结果,没有运气
ignore_default为真