Since v3.4.0, the rake tasks have been consolidated, and all of the tasks originally used for just SQL-backed indices now operate on both real-time and SQL-backed indices.
To process your data in indices, use the
Callbacks in your models should catch changes to your data with real-time indices, but it’s recommended you still run this task regularly to ensure your data is up-to-date.
It’s also worth noting that this task, run normally, will also generate the configuration file for Sphinx. If you decide to make custom changes, then you can disable this generation by running the task with the INDEX_ONLY environment variable set to true:
Index Guard Files
Any given SQL-backed index can not be processed more than once concurrently. To avoid multiple indexing requests, Thinking Sphinx adds a lock file in the indices directory while indexing occurs, named
In rare cases (generally when the parent process crashes completely), orphan lock files may remain - these are safe to remove if no indexing is occured. If you’re finding some of your indices aren’t being processed reliably, checking for these index files is recommended.
This feature has been in place since v3.1.0.
Generating the Configuration File
If you need to just generate the configuration file, without indexing (something that can be useful when deploying), here’s the task to do it:
Starting and Stopping Sphinx
If you actually want to search against the indexed data, then you’ll need Sphinx’s searchd daemon to be running. This can be controlled using the following tasks:
Rebuilding Sphinx Indexes
Whenever you change your index structures, or add or remove indices, you will need to regenerate your Sphinx data from scratch. This can be done with the
ts:rebuild task, which combines the following steps:
- Stop the Sphinx daemon (if it’s running) (
- Delete existing Sphinx data files (
- Rewrite the Sphinx configuration file (
- Populate data for SQL-backed indices (
- Start the Sphinx daemon (
- Populate data for real-time indices (
Legacy Real-Time Tasks
Prior to v3.4.0, the following tasks were used for managing real-time indices: