Search code examples
ruby-on-railssphinxthinking-sphinxreindex

Sphinx fails to reindex on Heroku


I have a Rails app using the following: Sphinx 2.2.11-id64-release (95ae9a6) Thinking Sphinx 4.4.1 Flying Sphinx 1.2.0

Currently I am successfully able to reindex (rake ts:rebuild) on development. When I do so, I see it generate development.sphinx.conf. When I push this to staging on heroku, I run the same command and get:

I, [2021-05-26T22:25:17.260156 #4]  INFO -- : [RailsAutoscale] Preparing middleware
D, [2021-05-26T22:25:17.404021 #4] DEBUG -- :    (1.5ms)  SET NAMES utf8,  @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'),  @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
searchd is not currently running.
D, [2021-05-26T22:25:17.988676 #4] DEBUG -- :    (2.5ms)  SET NAMES utf8,  @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'),  @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
Generating configuration to /app/config/staging.sphinx.conf
Generating configuration to /app/config/staging.sphinx.conf
sh: 1: indexer: not found

The Sphinx indexing command failed:
  Command: indexer --config "/app/config/staging.sphinx.conf" --all
  Status:  127
  Output:  See above

There may be more information about the failure in /app/log/staging.searchd.log.

I looked for the log, but I cannot find it. What I do know is that the staging config file is not being generated. If anyone has any clues to point me towards fixing this, I would be eternally grateful.


Solution

  • I think you may be in a situation where you're using older gems than the documentation expects. For flying-sphinx v1.x, you need to use the flying-sphinx executable instead of the ts:-prefixed rake tasks: heroku run bundle exec flying-sphinx rebuild.

    If you upgrade to flying-sphinx v2.x, then you'll be able to use the ts rake tasks on Heroku as well as locally. (Yes, this would have been the ideal behaviour from the get-go, but better late than never!)