views:

36

answers:

2

According to the documentation on Thinking Sphinx it should be possible to add a filter condition on id, but the following code does not give any results:

User.search(:without => {:id => [1,3]})

What am I doing wrong? Is there another way of doing this?

A: 

Why you don't use ActiveRecord for this simple query?

User.find(:all, :conditions => ["id NOT IN (?)", [1, 3]])
ipsum
That's indeed what I will, but this condition is part of a whole bunch of search conditions and it is so much easier with sphinx.
huug
+1  A: 

The solution is to define an index as follows:

define_index do
  has user(:id)
end
huug
This helped me as well. In my case I had to use 'pubs(:id)' so I guess you have to look at the plural if it doesn't work for you on the first try.
miccet