Thinking Sphinx v4.4.0 Release Notes
Release Date: 2019-08-21 // over 4 years ago-
โฌ๏ธ Upgrading
No breaking or major changes.
๐ New features
- ๐ Confirmed Rails 6.0 support.
- โ Added ability to have custom real-time index processors (which handles all indices) and populators (which handles a particular index). These are available to get/set via
ThinkingSphinx::RealTime.processor
andThinkingSphinx::RealTime.populator
.
๐จ The processor should accept
call
with two arguments: an array of index objects, and a block to invoke after each index is processed. Here is a simple example for parallel processing of indices:# Add the 'parallel' gem to your Gemfile.ThinkingSphinx::RealTime.processor = Proc.new do |indices, &block| Parallel.map(indices) do |index| puts "Populating index #{index.name}"ThinkingSphinx::RealTime.populator.populate index puts "Populated index #{index.name}" block.call endend
And the populator should respond to
populate
, accepting a single argument which is the index object. Here is a simple example for parallel processing.# Add the 'parallel' gem to your Gemfile.class ParallelPopulatordef self.populate(index) new(index).call enddef initialize(index) @index = index enddef callParallel.each(index.scope.find\_in\_batches) do |instances| transcriber.copy \*instances true # Don't emit any large object because results are accumulatedendActiveRecord::Base.connection.reconnect! endprivateattr\_reader :indexdef transcriber@transcriber ||= ThinkingSphinx::RealTime::Transcriber.new index endendThinkingSphinx::RealTime.populator = ParallelPopulator
๐ Instead of building your own procs/classes from scratch, you may instead wish to subclass the default classes to tweak behaviour - or at the very least, both classes are useful as reference points for your own replacements:
These changes were influenced by discussions in #1134 with @njakobsen about parallel processing of real-time indices.
๐ Changes to behaviour
- ๐ Improve failure message when tables don't exist for models associated with Sphinx indices (Kiril Mitov in #1139).
๐ Bug fixes
- 0๏ธโฃ Injected has-many/habtm collection search calls as default extensions to associations in Rails 5+, as it's a more reliable approach in Rails 6.0.0.