Вопрос

I am trying to perform the following search as 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 }

However I get the following error:

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

It seems like sphinx cannot handle the IN syntax here, but this does not make sense since it uses this in the configs.

I am not really sure how to move past this, any help or suggestions are appreciated! :)

Это было полезно?

Решение

IN() in Sphinx behaves a little differently to how you're using it - the 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}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top