ruby on rails - ultrasphinx

578 Views Asked by At

Ruby on Rails - UltraSphinx

Hi guys, I'm using Ultrasphinx for the search thing.

My question is : I have the "rake ultrasphinx:daemon:start" running in the background. Now, should I have a cron job that does "rake ultrasphinx:index" regularly or will the daemon take care of indexing whenever a new object is created.

Please, let me know. Its kind of emergency.

Thanks

2

There are 2 best solutions below

0
On BEST ANSWER

You will have to run a cron job to regularly update your index. However, you can run the rake task ultrasphinx:index:delta to only update the delta index which contains recently changed records.

From time to time, you might also want to merge your delta index into your main index using the task ultrasphinx:index:merge

Hope this helps.

1
On

add this to your model if you want to use delta indexing:

is_indexed :fields => ['column1', 'column2'], :delta => true
  1. Run ultrasphinx daemon:

    rake ultrasphinx:daemon:start

  2. Add to your CRON(I run it every 10 mins, but final decision is all up to your app): rake ultrasphinx:index:delta

  3. You will need to run rake ultrasphinx:index:main once a day to move the delta contents into the main index.

Source: official documentation.