Thinking Sphinx doesn’t execute query when you think it will

I was working late tonight (ok, technically it was last night, but the nights and days are blurry sometimes) and I was having trouble seeing a new ThinkingSphinx query in the searchd.query.log file.

After much WTF, I realized that I was not really using the search results yet. As a result of this I also discovered that Sphinx has a feature that it does a lazy execute of the search query. This is a great idea for performance, but when developing a search function it can be a bit maddening.

Fortunately there is a solution. ThinkingSphinx offers a property called :populate. Just set this property to true when searching and it will not wait for the lazy load.

Also as an aside and maybe another post when I figure out how to repeat it. If you make a change to class that is indexed and don’t restart the server, even in development there is a chance that when using the multi-class search ThinkingSphinx.search method you will get a strange error. Just restart the server and it will go away. When I get this to reproduce again I will capture the actual error.

This entry was posted in Ruby on Rails. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam Protection by WP-SpamFree