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 and ThinkingSphinx::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.