简体   繁体   English

使用OR的太阳黑子/ SOLR查询

[英]Sunspot/SOLR queries using OR

I'd like to setup Sunspot for a model as follows: 我想为模型设置太阳黑子如下:

Sunspot.search(Show) do
  with(:id).equal_to MY_QUERY.to_i
  OR
  with(:legacy_id).equal_to MY_QUERY.to_i
end

Is there a way to do Sunspot searches where it returns an Show that matches either of the conditions? 有没有办法进行太阳黑子搜索,它返回一个匹配任一条件的Show?

Thanks, 谢谢,

Joe

You can use any_of 你可以使用any_of

Sunspot.search(Show) do
  any_of do
    with(:id).equal_to MY_QUERY.to_i
    with(:legacy_id).equal_to MY_QUERY.to_i
  end
end

Hope this helps. 希望这可以帮助。 Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM