Class: ElastomerClient::Client::UpdateByQuery

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, query, parameters) ⇒ UpdateByQuery

Returns a new instance of UpdateByQuery.



35
36
37
38
39
# File 'lib/elastomer_client/client/update_by_query.rb', line 35

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

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



33
34
35
# File 'lib/elastomer_client/client/update_by_query.rb', line 33

def client
  @client
end

#parametersObject (readonly)

Returns the value of attribute parameters.



33
34
35
# File 'lib/elastomer_client/client/update_by_query.rb', line 33

def parameters
  @parameters
end

#queryObject (readonly)

Returns the value of attribute query.



33
34
35
# File 'lib/elastomer_client/client/update_by_query.rb', line 33

def query
  @query
end

Instance Method Details

#executeObject



41
42
43
44
45
46
47
# File 'lib/elastomer_client/client/update_by_query.rb', line 41

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