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?

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
huug
  • 1,059
  • 2
  • 11
  • 25

2 Answers2

2

The solution is to define an index as follows:

define_index do
  has user(:id)
end
huug
  • 1,059
  • 2
  • 11
  • 25
  • 1
    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 Oct 16 '10 at 08:55
0

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

User.find(:all, :conditions => ["id NOT IN (?)", [1, 3]])
ipsum
  • 1,042
  • 7
  • 17
  • 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 Sep 07 '10 at 14:13