views:

39

answers:

2

Hi, I have updated my searching fields records with thinking_sphinx gem and I have configured it. It is working fine but the problem, It is only displaying 20 records which is default. How to change those thing to make more records visible on view..

A: 

In your config/sphinx.yml (create one if you don't already have it) add the following:

development:
  max_matches: 10000
# ... repeat for other environments

See the docs for more info.

neutrino
I have tried it but result with same 20 records
Senthil Kumar Bhaskaran
have you run `rake ts:config` after that?
neutrino
Ya tried still no result
Senthil Kumar Bhaskaran
Thanks for ur guidance
Senthil Kumar Bhaskaran
+2  A: 

Neutrino is almost correct...

Firstly, it's worth noting that Sphinx (and so, Thinking Sphinx) always paginates requests, and the default page size is 20. If you'd like to change that, you can pass in :per_page => 30 or similar to get the number of records per page that you'd like.

Model.search 'foo', :per_page => 42

Secondly, Sphinx (by default) limits the total number of available search results to 1000 by default. This is what Neutrino was pointing out - if you set max_matches, you can increase that value. However, you will also need to specify a value for :max_matches in your search call as well.

Model.search 'foo', :max_matches => 10_000

You will need to stop/re-index/restart when you change values in your config/sphinx.yml file - there's a single rake task that does this:

rake ts:rebuild

This will ensure that the generated configuration file is up-to-date, and the Sphinx daemon is aware of the changes.

pat
Thanks I got it by using per_page with the search part.
Senthil Kumar Bhaskaran