Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update thinking-sphinx: 4.4.1 → 5.1.0 (major) #658

Merged
merged 1 commit into from Feb 23, 2021

Conversation

depfu[bot]
Copy link
Contributor

@depfu depfu bot commented Dec 29, 2020

Here is everything you need to know about this update. Please take a good look at what changed and the test results before merging this pull request.

What changed?

✳️ thinking-sphinx (4.4.1 → 5.1.0) · Repo · Changelog

Release Notes

5.1.0

Upgrading

No breaking or major changes.

New features

  • Support for Sphinx v3.3 and Manticore v3.5.
  • Support for Rails 6.1 (via joiner v0.6.0).

Changes to behaviour

  • enable_star is no longer available as a configuration option, as it's been enabled by default in Sphinx since v2.2.2, and is no longer allowed in Sphinx v3.3.1.
  • All timestamp attributes are now considered plain integer values from Sphinx's perspective. Sphinx was already expecting integers, but since Sphinx v3.3.1 it doesn't recognise timestamps as a data type. There is no functional difference with this change - Thinking Sphinx was always converting times to their UNIX epoch integer values.
  • Allow configuration of the maximum statement length (@kalsan in #1179).
  • Respect :path values to navigate associations for Thinking Sphinx callbacks on SQL-backed indices. Discussed in #1182.

Bug fixes

  • Don't attempt to update delta flags on frozen model instances.

5.0.0

Major Features and Breaking Changes

Thinking Sphinx v5.0 has one significant change - explicit callbacks - plus drops support for old versions of Rails/Ruby/Sphinx, and adds a few other smaller improvements.

Explicit Callbacks

Previous versions of Thinking Sphinx automatically added callbacks to all ActiveRecord models, for the purpose of persisting changes back to Sphinx (whether that be inserts, updates, or deletions). And while the actual overhead for non-indexed models wasn't super slow, it's still far from ideal.

So now, you need to add callbacks yourself, to just the models you're indexing.

With SQL-backed models (defined using :with => :active_record), you'll very likely want to add one of the two following lines inside your model:

class Article < ApplicationRecord
  # If you're not using delta indices:
  ThinkingSphinx::Callbacks.append(self, :behaviours => [:sql])

# If you are using delta indices:
ThinkingSphinx::Callbacks.append(self, :behaviours => [:sql, :deltas])
end

If you're using real-time indices, you very likely already have callbacks defined in your models, but you can replace them with the new calls:

class Article < ApplicationRecord
  # Instead of this...
  after_save ThinkingSphinx::RealTime.callback_for(:article)
  # use this...
  ThinkingSphinx::Callbacks.append(self, :behaviours => [:real_time])
end

For associated models which still fire real-time callbacks, you can use the :path option with the same call:

class Comment < ApplicationRecord
  belongs_to :article

ThinkingSphinx::Callbacks.append self,
:behaviours => [:real_time],
:path => [:article]
end

And if you're using a custom block with your old real-time callback, you can pass that same block to the new approach as well:

class Article < ApplicationRecord
  ThinkingSphinx::Callbacks.append(
    self, :behaviours => [:real_time]
  ) do |instance|
    # returning an array of instances to index. You could add
    # custom logic here if you don't want indexing to happen
    # in some cases.
  end
end

At this point in time, the older callback style for real-time indices will continue to work, but it's still recommended to update your code to the new style instead.

On the off chance you are using SQL-backed indices and you have attribute_updates enabled in config/thinking_sphinx.yml, you'll want to specify that in your :behaviours option:

ThinkingSphinx::Callbacks.append(self, :behaviours => [:sql, :updates])

Sphinx 2.2.11 or newer is required

Sphinx 2.1 is no longer supported - and ideally, it's best to upgrade any 2.2.x release to 2.2.11.

Sphinx 3.x releases are supported, but there are known issues with indexing SQL-backed indices on a PostgreSQL database (real-time indices are fine though).

As part of this change, Sphinx's docinfo setting is no longer configured, so the skip_docinfo setting in config/thinking_sphinx.yml can be removed.

When it comes to Manticore as a drop-in replacement for Sphinx, we're testing against the latest 2.x and 3.x releases, which are currently 2.8.2 and 3.4.2 respectively.

Ruby 2.4 or newer is required

Versions of Ruby less than 2.3 are no longer supported, sorry. We're currently testing against 2.4 through to 2.7.

Rails 4.2 or newer is required

It's been a long time coming, but Rails 3.2 (and 4.0 and 4.1) are no longer supported. The current supported versions are 4.2 through to 6.0 (and 6.1 will likely work as well, once it's released).

Other changes to behaviour

  • Remove internal uses of send, replaced with public_send as that's available in all supported Ruby versions.
  • Custom index_set_class implementations can now expect the :instances option to be set alongside :classes, which is useful in cases to limit the indices returned if you're splitting index data for given classes/models into shards. (Introduced in PR #1171 after discussions with @lunaru in #1166.)
  • Deletion statements are simplified by avoiding the need to calculate document keys/offsets (@njakobsen via #1134).
  • Real-time data is deleted before replacing it, to avoid duplicate data when offsets change (@njakobsen via #1134).
  • Use reference_name as per custom index_set_class definitions. Previously, the class method was called on ThinkingSphinx::IndexSet even if a custom subclass was configured. (As per discussions with @kalsan in #1172.)
  • Fields and attributes can be overriden - whichever's defined last with a given name is the definition that's used. This is an edge case, but useful if you want to override any of the default fields/indices. (Requested by @kalsan in #1172.)

Bug fixes

None.

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by 48 commits:

↗️ i18n (indirect, 1.8.8 → 1.8.9) · Repo · Changelog

Release Notes

1.8.9

  • Rely on Ruby 3's native Hash#except method -- #557

This release also contains several build related updates -- rather than listing them out here, you can see the compare view between 1.8.8 and 1.8.9.

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by 10 commits:

↗️ riddle (indirect, 2.4.0 → 2.4.2) · Repo · Changelog

Commits

See the full diff on Github. The new version differs by 10 commits:


Depfu Status

Depfu will automatically keep this PR conflict-free, as long as you don't add any commits to this branch yourself. You can also trigger a rebase manually by commenting with @depfu rebase.

All Depfu comment commands
@​depfu rebase
Rebases against your default branch and redoes this update
@​depfu recreate
Recreates this PR, overwriting any edits that you've made to it
@​depfu merge
Merges this PR once your tests are passing and conflicts are resolved
@​depfu close
Closes this PR and deletes the branch
@​depfu reopen
Restores the branch and reopens this PR (if it's closed)
@​depfu pause
Ignores all future updates for this dependency and closes this PR
@​depfu pause [minor|major]
Ignores all future minor/major updates for this dependency and closes this PR
@​depfu resume
Future versions of this dependency will create PRs again (leaves this PR as is)

@hennevogel
Copy link
Member

@depfu rebase

@depfu depfu bot force-pushed the depfu/update/thinking-sphinx-5.1.0 branch from c63897b to 4f9c31b Compare February 23, 2021 17:11
@hennevogel hennevogel merged commit e00a653 into master Feb 23, 2021
@depfu depfu bot deleted the depfu/update/thinking-sphinx-5.1.0 branch February 23, 2021 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant