Sha256: d34874a8cb04a8489ba08744a609551ce54ac67b775e6c8bcd483eb4f8ea2b47

Contents?: true

Size: 951 Bytes

Versions: 17

Compression:

Stored size: 951 Bytes

Contents

# frozen_string_literal: true

class ThinkingSphinx::Interfaces::RealTime < ThinkingSphinx::Interfaces::Base
  def initialize(configuration, options, stream = STDOUT)
    super

    configuration.preload_indices

    command :prepare
  end

  def clear
    command :clear_real_time, :indices => indices
  end

  def index
    return if indices.empty?
    if !command :running
      stream.puts <<-TXT
The Sphinx daemon is not currently running. Real-time indices can only be
populated by sending commands to a running daemon.
      TXT
      return
    end

    command :index_real_time, :indices => indices
  end

  private

  def index_names
    @index_names ||= options[:index_names] || []
  end

  def indices
    @indices ||= begin
      indices = configuration.indices.select { |index| index.type == 'rt' }

      if index_names.any?
        indices.select! { |index| index_names.include? index.name }
      end

      indices
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
thinking-sphinx-5.6.0 lib/thinking_sphinx/interfaces/real_time.rb
thinking-sphinx-5.5.1 lib/thinking_sphinx/interfaces/real_time.rb
thinking-sphinx-5.5.0 lib/thinking_sphinx/interfaces/real_time.rb
thinking-sphinx-5.4.0 lib/thinking_sphinx/interfaces/real_time.rb
thinking-sphinx-5.3.0 lib/thinking_sphinx/interfaces/real_time.rb
thinking-sphinx-5.2.1 lib/thinking_sphinx/interfaces/real_time.rb
thinking-sphinx-5.2.0 lib/thinking_sphinx/interfaces/real_time.rb
thinking-sphinx-5.1.0 lib/thinking_sphinx/interfaces/real_time.rb
thinking-sphinx-5.0.0 lib/thinking_sphinx/interfaces/real_time.rb
thinking-sphinx-4.4.1 lib/thinking_sphinx/interfaces/real_time.rb
thinking-sphinx-4.4.0 lib/thinking_sphinx/interfaces/real_time.rb
thinking-sphinx-4.3.2 lib/thinking_sphinx/interfaces/real_time.rb
thinking-sphinx-4.3.1 lib/thinking_sphinx/interfaces/real_time.rb
thinking-sphinx-4.3.0 lib/thinking_sphinx/interfaces/real_time.rb
thinking-sphinx-4.2.0 lib/thinking_sphinx/interfaces/real_time.rb
thinking-sphinx-4.1.0 lib/thinking_sphinx/interfaces/real_time.rb
thinking-sphinx-4.0.0 lib/thinking_sphinx/interfaces/real_time.rb