Skip to content

v3.1.0

Compare
Choose a tag to compare
@pat pat released this 11 Jan 13:34

New Features

Thinking Sphinx v3.1.0 is the first v3 release to support JRuby. You'll need the jdbc-mysql gem as well, and then it'll be smooth sailing. However, Rails 3.1 and MRI 1.9.2 are no longer supported - please upgrade to 3.2 and 1.9.3 (or 2.0.0/2.1.0) respectively.

Upgrading

Sphinx Versions

Thinking Sphinx now expects Sphinx v2.1.2 or newer by default. If you're using v2.1.2, or something newer than that, then you should not make any of the changes listed in this section.

However, If you're using Sphinx 2.1.1 or earlier, you'll want to add these lines to an initializer:

ThinkingSphinx::Middlewares::DEFAULT.insert_after(
  ThinkingSphinx::Middlewares::Inquirer, ThinkingSphinx::Middlewares::UTF8
)
ThinkingSphinx::Middlewares::RAW_ONLY.insert_after(
  ThinkingSphinx::Middlewares::Inquirer, ThinkingSphinx::Middlewares::UTF8
)

And add the following setting to config/thinking_sphinx.yml:

development:
  utf8: false
# repeat for each environment as necessary

If you're using Sphinx 2.0.x, you'll also need to put the following in an initializer as well:

ThinkingSphinx::SphinxQL.variables!

Custom SELECT Statements

If you're sending through custom SELECT statements via the :select option in search calls, please note that you'll need to supply * or specific column names to have them returned (the * is no longer supplied by default if you're setting something custom). So:

Article.search 'pancakes', :select => 'weight() as w'
# becomes
Article.search 'pancakes', :select => '*, weight() as w'

If you don't want to return all the columns/attributes, but you do want ActiveRecord objects instantiated in your search results, you'll need to include the sphinx_internal_id and sphinx_internal_class columns. It's also worth noting that any attribute you refer to in other parts of the query (for example, the ORDER clause) must exist in your SELECT clause.

Capistrano

Capistrano v3 is now supported, and there are now cap tasks for real-time indices (thinking_sphinx:generate and thinking_sphinx:regenerate). There's no longer any automatic symlinking of directories - it's recommended that pid, index and configuration files are all located in the shared directory permanently, using something like the following in your config/thinking_sphinx.yml file:

production:
  pid_file: /path/to/app/shared/tmp/searchd.pid
  indices_location: /path/to/app/shared/db/sphinx
  configuration_file: /path/to/app/shared/production.sphinx.conf

Also: previously, thinking_sphinx:index and thinking_sphinx:start would automatically run after deploy:cold. This is no longer the case, partially because the behaviour is different with real-time indices, and partially because it's better for you to have control over those decisions instead.

New features

  • Set custom database settings within the index definition, using the set_database method within a index definition block. You can either pass in a database settings hash (like what would exist in database.yml), or an environment name which corresponds to a known database configuration.
  • All delta records can have their core pairs marked as deleted after a suspended delta (use ThinkingSphinx::Deltas.suspend_and_update instead of ThinkingSphinx::Deltas.suspend).
  • Pass through :delta_options to delta processors in index definitions (Timo Virkalla).
  • Track what's being indexed, and don't double-up while indexing is running. Single indices (e.g. deltas) can be processed while a full index is happening, though.
  • Persistent connections can be disabled if you wish (ThinkingSphinx::Connection.persistent = false).
  • :group option within :sql options in a search call is passed through to the underlying ActiveRecord relation (Siarhei Hanchuk).
  • Capistrano recipe now includes tasks for realtime indices.
  • Wildcard/starring can be applied directly to strings using ThinkingSphinx::Query.wildcard('pancakes'), and escaping via ThinkingSphinx::Query.escape('pancakes').
  • Adding max_predicted_time search option (Sphinx 2.2.x).
  • Support for Sphinx 2.2.x's HAVING and GROUP N BY SphinxQL options (via :having and :group_best options respectively).
  • JRuby support (with Sphinx 2.1 or newer).
  • Support for Capistrano v3 (Alexander Tipugin).

Changes to behaviour

  • Provide a distributed index per model that covers both core and delta indices.
  • Reset the delta column to true after core indexing is completed, instead of before, and don't filter out delta records from the core source.
  • Insist on at least * for SphinxQL SELECT statements.
  • MRI 1.9.2 is no longer supported.
  • Rails 3.1 is no longer supported.
  • Sphinx functions are now the default, instead of the legacy special variables (in line with Sphinx 2.1.x).
  • UTF-8 forced encoding is now disabled by default (in line with Sphinx 2.1.x).
  • Capistrano recipe no longer automatically adds thinking_sphinx:index and thinking_sphinx:start to be run after deploy:cold.
  • Auto-wildcard/starring (via :star => true) now treats escaped characters as word separators.
  • Geodist calculation is now prepended to the SELECT statement, so it can be referred to by other dynamic attributes (order matters in SELECT statements).
  • Extracting join generation into its own gem: Joiner.
  • Updating Riddle requirement to >= 1.5.10.

Bug fixes

  • Don't split function calls when casting timestamps (Timo Virkalla).
  • Separate per_page/max_matches values are respected in facet searches (Timo Virkkala).
  • Track indices on parent STI models when marking documents as deleted.
  • Blank STI values are converted to the parent class in Sphinx index data (Jonathan Greenberg).
  • Destroy callbacks are ignored for non-persisted objects.
  • Indices will be detected in Rails engines upon configuration.