class Tire::DeleteByQuery

Attributes

indices[R]
json[R]
query[R]
response[R]
types[R]

Public Class Methods

new(indices=nil, options={}, &block) click to toggle source
# File lib/tire/delete_by_query.rb, line 7
def initialize(indices=nil, options={}, &block)
  @indices = Array(indices)
  @types   = Array(options[:type]).flatten
  @options = options

  if block_given?
    @query = Search::Query.new
    block.arity < 1 ? @query.instance_eval(&block) : block.call(@query)
  else
    raise "no query given for #{self.class}"
  end
end

Public Instance Methods

perform() click to toggle source
# File lib/tire/delete_by_query.rb, line 20
def perform
  @response = Configuration.client.delete url
  if @response.failure?
    STDERR.puts "[REQUEST FAILED] #{self.to_curl}\n"
    raise DeleteByQueryRequestFailed, @response.to_s
  end
  @json = MultiJson.decode(@response.body)
  true
ensure
  logged
end