【问题标题】:Thinking Sphinx and ActiveRecord default_scope思考 Sphinx 和 ActiveRecord default_scope
【发布时间】:2011-11-19 13:46:54
【问题描述】:

有什么方法可以跳过将 ActiveRecord::Base 的 default_scope 应用到 Thinking Sphinx 的搜索结果?

https://gist.github.com/1378847

【问题讨论】:

    标签: ruby-on-rails activerecord thinking-sphinx


    【解决方案1】:

    在调用搜索之前使用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(...)},都返回了作用域结果
    • @Marc,你不认为这是 Thinking Sphinx 的错误吗,第 89 行“options”之前的“@”不见了
    • Article.search(keywords, :ignore_default => true) 返回范围内的结果,没有运气
    • here可以看出,默认ignore_default为真
    • 获取“Article.search(keywords)”上的 to_sql。然后我们可以调查sql或索引是否有问题。
    猜你喜欢
    • 1970-01-01
    • 2023-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多