我正在尝试执行以下搜索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语法,但这没有意义,因为它在配置中使用它。
我不确定如何超越这个,任何帮助或建议都表示赞赏! :)
答案 0 :(得分:1)
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}