ThinkingSphinx& Rails 3 - 如何在属性过滤器上使用OR逻辑?

时间:2014-03-12 21:05:31

标签: sphinx thinking-sphinx

我正在尝试执行以下搜索per the docs

with_delivery = "*, IF(delivery = 1 OR region_id IN (001,002,003), 1, 0) AS delivery"
Listing.search 'ipod', 
                select: with_delivery, 
                with: { 'delivery' => 1 }

但是我收到以下错误:

 ThinkingSphinx::SyntaxError: sphinxql: syntax error, unexpected IN, expecting ',' or ')' near 'IN (001...

似乎sphinx在这里无法处理IN语法,但这没有意义,因为它在配置中使用它。

我不确定如何超越这个,任何帮助或建议都表示赞赏! :)

1 个答案:

答案 0 :(得分:1)

Sphinx中的

IN()与您使用它的方式略有不同 - first argument should be the attribute

with_delivery = "*, IF(delivery = 1 OR IN(region_id, 1, 2, 3), 1, 0) AS delivery"
Listing.search 'ipod', 
  select: with_delivery, 
  with:   {delivery: 1}