views:

145

answers:

3

I have a simple query to show users that are active, but somehow it is still showing inactive users. I am using sphinx. The query looks like:

User.search keywords,:conditions=>conditions, :match_mode=>:boolean, :order =>sort_order.to_s, :page => page,:per_page =>per_page

the conditions hash looks like this:

conditions = {:is_expired => false, :is_disabled => false,...}

the condiitions include: :is_expired => false, yet it fetches those users which have :is_expired = true.

What do i need to do to make it only fetch those records that are not expired?

+1  A: 

Make sure you index the is_expired and the is_disabled methods. Apologies if you have done so already.

allesklar
+1  A: 

i changed the type of the column from boolean to integer, and it started working!

Edit: actually it started working locally, and not on production. I finally looked at the output of executing the command RAILS_ENV=production rake thinking_sphinx:index and saw a line that read something like: ERROR: index 'user_core': failed to create /path/to/application/production/user_core.spm: Permission denied.

Then i saw that the file permission was of "root root" instead of the user who runs the index command. This was because once the deployer did a "sudo su -" etc to deploy, and the new files created were with root as creator etc. I had to delete the file and it started working correctly after running the index command. I am not sure whether now i can revert from integer column type to boolean though.

+2  A: 

Check out ThinkingSphinx

Reuben Mallaby