Ruby on rails 斯芬克斯与参数结合的思考
我想知道如何将斯芬克斯思考的结果集结合起来 我有以下疑问:Ruby on rails 斯芬克斯与参数结合的思考,ruby-on-rails,full-text-search,thinking-sphinx,Ruby On Rails,Full Text Search,Thinking Sphinx,我想知道如何将斯芬克斯思考的结果集结合起来 我有以下疑问: Model.search :with => {:attribute_1 => id} 我想与之结合: Model.search :with => {:attribute_2 => id} 有没有一个简单的方法只需一次搜索就可以做到这一点?我可以做数组加法,但这似乎根本不是一个好的解决方案。如果我像这样组合过滤器: Model.search :with => {:attribute_1 => id,
Model.search :with => {:attribute_1 => id}
我想与之结合:
Model.search :with => {:attribute_2 => id}
有没有一个简单的方法只需一次搜索就可以做到这一点?我可以做数组加法,但这似乎根本不是一个好的解决方案。如果我像这样组合过滤器:
Model.search :with => {:attribute_1 => id, :attribute_2 => id}
结果是两个过滤器的交集,这不是期望的输出。是否有任何方法可以对过滤器执行OR操作。这实际上归结为Sphinx中的一个限制-在引用过滤器中的属性时,Sphinx没有OR的概念 也许您可以将这两个属性组合在一起?那么下面的方法就行了:
Model.search :with => {:attr_1_and_2 => id}
在您的模型中,如果您处理的是单个值,那么这肯定会起作用——可能还有值数组:
has [attribute_1, attribute2], :as => :attr_1_and_2
我想这正是我想要的。谢谢你的提示!