Note that this article is no longer that useful. Instead of named scopes please look at sphinx scopes. Article coming soon.
One of the first gotchas (covered here too) is that if you actually inspect that array you'll see that it's filled with nil.
[nil, nil, nil, nil nil,nil, nil, nil, nil nil,nil, nil, nil, nil nil,nil, nil, nil, nil nil,]
To get around it, call the compact method on the array:
The other gotcha here is that if you actually have 20000 records that match "injector" but only 1 of them is current, you'll get zero results. To work around that you need to increase the maximum amount of results per page:
@p =Product.current.search("injector", :per_page => 20000).compact.size
But what about pagination? Thinking Sphinx does give us this, but the fact that both the methods are called :per_page kind of screws things up. To work around this, just call paginate on your results:
:per_page => 20000).paginate(:per_page => 8, :page => params[:page])
And that should do it. Of course, depending on how many results you have you may need to up the initial per_page from 20000 to something larger. This isn't ideal in my humble opinion, but it works for the moment. Other suggestions are welcome!
While we're on the subject of Thinking Sphinx, be sure to set :enable_star => 1 in your index block if you want to use wildcards in your searches.