Is it possible to use multiple "OR" conditions with collection of ids?

eg. user_id in(1,2,3) or category_id in(1,23,45) or category_id2
in(23,45,67)

Here is the model:

define_index do
  indexes created_at
  has :id
  has user_id
  has category_id
  has category_id2
  has category_id3
  set_property :enable_star => true
  set_property :min_prefix_len => 1
end

The first attempt was:

Example.search(:with=>{:category_id=>[1,2,3],:category_id2=>[23,45,56],:category_id3=>[67,77,89,23]})

BUT it searches with "AND" condition

The second attempt was:

with_display = "*, (category_id in(1,2,3) OR category_id2 in(5,
1,23,56) OR category_id3 in(23,45,67)) AS display"
Example.search (:sphinx_select => with_display,:with=> {'display' =>
1})

This works when passing a single ID for each category but with a
collection it generates an error in console:

Riddle::ResponseError: searchd error (status: 1): select: syntax
error, unexpected ','

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en.

Reply via email to