Installing Thinking Sphinx
Thinking Sphinx v5 supports Rails 4.2, 5.x and 6.x.
Note: Thinking Sphinx v5.x (as documented here) is written for Ruby 2.4+. For older Ruby support, please refer to previous versions of Thinking Sphinx.
Sphinx communicates via the MySQL protocol, and so you will need a MySQL gem to allow Thinking Sphinx to make queries to Sphinx.
- For standard (MRI) Ruby, use the
mysql2gem (v0.4 or newer).
- For JRuby, use the
Even if you’re using PostgreSQL, you will still need to have the mysql2 gem installed (along with the
pg gem too, of course).
Install them like you would any other gem - either manually:
Or by adding them to your Gemfile:
jdbc-mysql after 5.1.35 have altered behaviour that is not compatible with Sphinx.
You can also refer directly to the git repository - but if you’re doing this, specifying the version, branch and commit reference is recommended so when you next go to upgrade the gem, it’s clear what you were using (and perhaps why). The
develop branch is where commits are pushed between version releases. The
master branch is only updated when a new version is released.
When you start Sphinx, a new folder called
/db/sphinx will be created. The files contained are equivalent to your database’s data files, and should be not be committed into version control.
It’s also recommended that you ignore the
Add the following lines to your
.gitignore file to ignore these files:
Using Thinking Sphinx with Unicorn
If you’re using Unicorn as your web server, you’ll want to ensure the connection pool is cleared after forking.