class ThinkingSphinx::Commands::MergeAndUpdate
Public Instance Methods
call()
click to toggle source
# File lib/thinking_sphinx/commands/merge_and_update.rb, line 4 def call configuration.preload_indices configuration.render index_pairs.each do |(core_index, delta_index)| command :merge, :core_index => core_index, :delta_index => delta_index, :filters => {:sphinx_deleted => 0} core_index.model.where(:delta => true).update_all(:delta => false) end end
Private Instance Methods
core_indices()
click to toggle source
# File lib/thinking_sphinx/commands/merge_and_update.rb, line 22 def core_indices indices.select { |index| !index.delta? }.select do |index| name_filters.empty? || name_filters.include?(index.name.gsub(/_core$/, '')) end end
delta_for(core_index)
click to toggle source
# File lib/thinking_sphinx/commands/merge_and_update.rb, line 29 def delta_for(core_index) name = core_index.name.gsub(/_core$/, "_delta") indices.detect { |index| index.name == name } end
index_pairs()
click to toggle source
# File lib/thinking_sphinx/commands/merge_and_update.rb, line 34 def index_pairs core_indices.collect { |core_index| [core_index, delta_for(core_index)] } end
indices()
click to toggle source
# File lib/thinking_sphinx/commands/merge_and_update.rb, line 40 def indices @indices ||= configuration.indices.select { |index| index.type == "plain" && index.options[:delta_processor] } end
indices_exist?(*indices)
click to toggle source
# File lib/thinking_sphinx/commands/merge_and_update.rb, line 46 def indices_exist?(*indices) indices.all? { |index| File.exist?("#{index.path}.spi") } end
name_filters()
click to toggle source
# File lib/thinking_sphinx/commands/merge_and_update.rb, line 50 def name_filters @name_filters ||= options[:index_names] || [] end
type()
click to toggle source
# File lib/thinking_sphinx/commands/merge_and_update.rb, line 54 def type 'merging_and_updating' end