Class: ElastomerClient::Client::NativeDeleteByQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/elastomer_client/client/native_delete_by_query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, query, parameters) ⇒ NativeDeleteByQuery

Returns a new instance of NativeDeleteByQuery.



25
26
27
28
29
# File 'lib/elastomer_client/client/native_delete_by_query.rb', line 25

def initialize(client, query, parameters)
  @client = client
  @query = query
  @parameters = parameters
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



23
24
25
# File 'lib/elastomer_client/client/native_delete_by_query.rb', line 23

def client
  @client
end

#parametersObject (readonly)

Returns the value of attribute parameters.



23
24
25
# File 'lib/elastomer_client/client/native_delete_by_query.rb', line 23

def parameters
  @parameters
end

#queryObject (readonly)

Returns the value of attribute query.



23
24
25
# File 'lib/elastomer_client/client/native_delete_by_query.rb', line 23

def query
  @query
end

Instance Method Details

#executeObject



31
32
33
34
35
36
37
# File 'lib/elastomer_client/client/native_delete_by_query.rb', line 31

def execute
  # TODO: Require index parameter. type is optional.
  updated_params = parameters.merge(body: query, action: "delete_by_query", rest_api: "delete_by_query")
  updated_params.delete(:type) if client.version_support.es_version_8_plus?
  response = client.post("/{index}{/type}/_delete_by_query", updated_params)
  response.body
end