class ThinkingSphinx::Deletion

Attributes

ids[R]
index[R]

Public Class Methods

new(index, ids) click to toggle source
# File lib/thinking_sphinx/deletion.rb, line 15
def initialize(index, ids)
  @index, @ids = index, Array(ids)
end
perform(index, ids) click to toggle source
# File lib/thinking_sphinx/deletion.rb, line 4
def self.perform(index, ids)
  return if index.distributed?

  {
    'plain' => PlainDeletion,
    'rt'    => RealtimeDeletion
  }[index.type].new(index, ids).perform
rescue ThinkingSphinx::ConnectionError => error
  # This isn't vital, so don't raise the error.
end

Private Instance Methods

document_ids_for_keys() click to toggle source
# File lib/thinking_sphinx/deletion.rb, line 23
def document_ids_for_keys
  ids.collect { |id| index.document_id_for_key id }
end
execute(statement) click to toggle source
# File lib/thinking_sphinx/deletion.rb, line 27
def execute(statement)
  statement = statement.gsub(/\s*\n\s*/, ' ').strip

  ThinkingSphinx::Logger.log :query, statement do
    ThinkingSphinx::Connection.take do |connection|
      connection.execute statement
    end
  end
end