Invoking a rake task to rebuild a flying sphinx index

134 views
Skip to first unread message

bruno

unread,
May 28, 2012, 1:07:36 PM5/28/12
to thinkin...@googlegroups.com
Hi,

We have a Rails app deployed on Heroku and we're using Flying Sphinx (Wooden plan) for some easy facets on a page. As part of our app, when an administrator disables certain year ranges, we want to remove those from the index so they don't show up on the facets. On development, we submit a resque job that then invokes: 

require 'thinking_sphinx/tasks'
Rake::Task['ts:rebuild'].invoke

Since these operations happen seldomly (the admin removing a year range from the products we have on index) we decided not to add to the complexity of running Delta Indexes however the more I read about Flying Sphinx vs Thinking Sphinx, it seems that this will be the only way to run this in production/Heroku? The main reason we went this way is that we are using Resque and not Delayed Job ... I tried:

      require 'flying_sphinx/tasks'
      Rake::Task['fs:rebuild'].invoke

however I am getting the following message:

RuntimeError: Don't know how to build task 'environment'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task_manager.rb:49:in `[]'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:60:in `lookup_prerequisite'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:56:in `block in prerequisite_tasks'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:56:in `collect'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:56:in `prerequisite_tasks'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
from /usr/local/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
from (irb):4
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/commands/console.rb:47:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/commands/console.rb:8:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

So, I am a bit at a loss ... maybe someone has an alternative for this that I can use? Maybe there's a resque job/gem that I can use?

Thanks for any help/direction.

/B

Pat Allan

unread,
Jun 6, 2012, 4:45:02 PM6/6/12
to thinkin...@googlegroups.com
Hi Bruno

So sorry for taking so long to get back to you on this. The ts-resque-delta gem supports Flying Sphinx (because I submitted a patch for it), so you should be able to use that without too much hassle - something like this should do the trick:

set_property :delta => FlyingSphinx::ResqueDelta

And you'll probably need to manually require 'flying_sphinx/resque_delta' somewhere (such as in an initialiser).

Let me know how you go!

Cheers

--
Pat

> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/-bLV04oQK-oJ.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.



Reply all
Reply to author
Forward
0 new messages