pat / thinking-sphinx

Sphinx/Manticore plugin for ActiveRecord/Rails
http://freelancing-gods.com/thinking-sphinx
MIT License
1.63k stars 468 forks source link

Disabling in Development #1212

Closed DaAwesomeP closed 2 years ago

DaAwesomeP commented 2 years ago

Hello,

Is it possible to disable/ignore errors for Thinksing Sphinx when in a certain Rails env? I'm trying to add an option to not have Sphinx installed in the development environment. Specifically seeing Riddle::CommandFailedError: Sphinx command failed to execute.

Thanks!

pat commented 2 years ago

There's no global option for this. But I'm curious: at what points are you seeing these errors? Is it via real-time/delta callbacks?

DaAwesomeP commented 2 years ago

Yeah, callbacks when creating or modifying a model that gets indexed (delta is enabled). If I disabled the index I guess that would do it.

pat commented 2 years ago

If you're using real-time indices (as opposed to deltas) you could add real_time_callbacks: false for the development environment in config/thinking_sphinx.yml, which should do the trick.

There's not an equivalent setting for deltas though.

pat commented 2 years ago

Ah, you've said you're using deltas! Sorry… you could change it that deltas aren't enabled in development, in each index file. e.g.

ThinkingSphinx::Index.define :article, :with => :active_record, :delta => !Rails.env.development? do
DaAwesomeP commented 2 years ago

Yup, that did the trick! Thanks!