module Elasticsearch::API::Actions

Public Instance Methods

abort_benchmark(arguments = {}) click to toggle source

Abort a running benchmark

@example

client.abort_benchmark name: 'my_benchmark'

@option arguments [String] :name A benchmark name

@see www.elastic.co/guide/en/elasticsearch/reference/master/search-benchmark.html

# File lib/elasticsearch/api/actions/abort_benchmark.rb, line 31
def abort_benchmark(arguments = {})
  method = HTTP_POST
  path   = "_bench/abort/#{arguments[:name]}"
  params = {}
  body   = nil

  perform_request(method, path, params, body).body
end
benchmark(arguments = {}) click to toggle source

Run a single query, or a set of queries, and return statistics on their performance

@example Return statistics for a single query

client.benchmark body: {
  name: 'my_benchmark',
  competitors: [
    {
      name: 'query_1',
      requests: [
        { query: { match: { _all: 'a*' } } }
      ]
    }
  ]
}

@example Return statistics for a set of “competing” queries

client.benchmark body: {
  name: 'my_benchmark',
  competitors: [
    {
      name: 'query_a',
      requests: [
        { query: { match: { _all: 'a*' } } }
      ]
    },
    {
      name: 'query_b',
      requests: [
        { query: { match: { _all: 'b*' } } }
      ]
    }
  ]
}

@option arguments [List] :index A comma-separated list of index names; use `_all` or empty string

to perform the operation on all indices

@option arguments [String] :type The name of the document type @option arguments [Hash] :body The search definition using the Query DSL @option arguments [Boolean] :verbose Specify whether to return verbose statistics about each iteration

(default: false)

@see www.elastic.co/guide/en/elasticsearch/reference/master/search-benchmark.html

# File lib/elasticsearch/api/actions/benchmark.rb, line 66
def benchmark(arguments = {})
  method = HTTP_PUT
  path   = "_bench"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
  body   = arguments[:body]

  perform_request(method, path, params, body).body
end
bulk(arguments = {}) click to toggle source

Allows to perform multiple index/update/delete operations in a single request.

@option arguments [String] :index Default index for items which don't provide one @option arguments [String] :type Default document type for items which don't provide one @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. (options: true, false, wait_for) @option arguments [String] :routing Specific routing value @option arguments [Time] :timeout Explicit operation timeout @option arguments [List] :_source True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request @option arguments [List] :_source_excludes Default list of fields to exclude from the returned _source field, can be overridden on each sub-request @option arguments [List] :_source_includes Default list of fields to extract and return from the _source field, can be overridden on each sub-request @option arguments [String] :pipeline The pipeline id to preprocess incoming documents with @option arguments [Boolean] :require_alias Sets require_alias for all incoming documents. Defaults to unset (false) @option arguments [Hash] :headers Custom HTTP headers @option arguments [String|Array] :body The operation definition and data (action-data pairs), separated by newlines. Array of Strings, Header/Data pairs, or the conveniency “combined” format can be passed, refer to Elasticsearch::API::Utils.__bulkify documentation.

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/docs-bulk.html

# File lib/elasticsearch/api/actions/bulk.rb, line 40
def bulk(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_POST
  path   = if _index && _type
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_bulk"
           elsif _index
             "#{Utils.__listify(_index)}/_bulk"
           else
             "_bulk"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  if body.is_a? Array
    payload = Elasticsearch::API::Utils.__bulkify(body)
  else
    payload = body
  end

  headers.merge!("Content-Type" => "application/x-ndjson")
  perform_request(method, path, params, payload, headers).body
end
clear_scroll(arguments = {}) click to toggle source

Explicitly clears the search context for a scroll.

@option arguments [List] :scroll_id A comma-separated list of scroll IDs to clear Deprecated @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter

*Deprecation notice*: A scroll id can be quite large and should be specified as part of the body Deprecated since version 7.0.0

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/clear-scroll-api.html

# File lib/elasticsearch/api/actions/clear_scroll.rb, line 34
def clear_scroll(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _scroll_id = arguments.delete(:scroll_id)

  method = Elasticsearch::API::HTTP_DELETE
  path   = if _scroll_id
             "_search/scroll/#{Utils.__listify(_scroll_id)}"
           else
             "_search/scroll"
           end
  params = {}

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
close_point_in_time(arguments = {}) click to toggle source

Close a point in time

@option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body a point-in-time id to close

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/point-in-time-api.html

# File lib/elasticsearch/api/actions/close_point_in_time.rb, line 28
def close_point_in_time(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_DELETE
  path   = "_pit"
  params = {}

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
count(arguments = {}) click to toggle source

Returns number of documents matching a query.

@option arguments [List] :index A comma-separated list of indices to restrict the results @option arguments [List] :type A comma-separated list of types to restrict the results @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) @option arguments [Boolean] :ignore_throttled Whether specified concrete, expanded or aliased indices should be ignored when throttled @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) @option arguments [Number] :min_score Include only documents with a specific `_score` value in the result @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) @option arguments [List] :routing A comma-separated list of specific routing values @option arguments [String] :q Query in the Lucene query string syntax @option arguments [String] :analyzer The analyzer to use for the query string @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed (default: false) @option arguments [String] :default_operator The default operator for query string query (AND or OR) (options: AND, OR) @option arguments [String] :df The field to use as default where no field prefix is given in the query string @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored @option arguments [Number] :terminate_after The maximum count for each shard, upon reaching which the query execution will terminate early @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body A query to restrict the results specified with the Query DSL (optional)

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/search-count.html

# File lib/elasticsearch/api/actions/count.rb, line 49
def count(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_POST
  path   = if _index && _type
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_count"
           elsif _index
             "#{Utils.__listify(_index)}/_count"
           else
             "_count"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
create(arguments = {}) click to toggle source

Creates a new document in the index.

Returns a 409 response when a document with a same ID already exists in the index.

@option arguments [String] :id Document ID @option arguments [String] :index The name of the index @option arguments [String] :type The type of the document Deprecated @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. (options: true, false, wait_for) @option arguments [String] :routing Specific routing value @option arguments [Time] :timeout Explicit operation timeout @option arguments [Number] :version Explicit version number for concurrency control @option arguments [String] :version_type Specific version type (options: internal, external, external_gte) @option arguments [String] :pipeline The pipeline id to preprocess incoming documents with @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The document (Required)

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/docs-index_.html

# File lib/elasticsearch/api/actions/create.rb, line 45
def create(arguments = {})
  if arguments[:id]
    index arguments.update op_type: 'create'
  else
    index arguments
  end
end
delete(arguments = {}) click to toggle source

Removes a document from the index.

@option arguments [String] :id The document ID @option arguments [String] :index The name of the index @option arguments [String] :type The type of the document Deprecated @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. (options: true, false, wait_for) @option arguments [String] :routing Specific routing value @option arguments [Time] :timeout Explicit operation timeout @option arguments [Number] :if_seq_no only perform the delete operation if the last operation that has changed the document has the specified sequence number @option arguments [Number] :if_primary_term only perform the delete operation if the last operation that has changed the document has the specified primary term @option arguments [Number] :version Explicit version number for concurrency control @option arguments [String] :version_type Specific version type (options: internal, external, external_gte, force) @option arguments [Hash] :headers Custom HTTP headers

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/docs-delete.html

# File lib/elasticsearch/api/actions/delete.rb, line 43
def delete(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _id = arguments.delete(:id)

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_DELETE
  path   = if _index && _type && _id
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}"
           else
             "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  if Array(arguments[:ignore]).include?(404)
    Utils.__rescue_from_not_found { perform_request(method, path, params, body, headers).body }
  else
    perform_request(method, path, params, body, headers).body
  end
end
delete_by_query(arguments = {}) click to toggle source

Deletes documents matching the provided query.

@option arguments [List] :index A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices (Required) @option arguments [List] :type A comma-separated list of document types to search; leave empty to perform the operation on all types @option arguments [String] :analyzer The analyzer to use for the query string @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed (default: false) @option arguments [String] :default_operator The default operator for query string query (AND or OR) (options: AND, OR) @option arguments [String] :df The field to use as default where no field prefix is given in the query string @option arguments [Number] :from Starting offset (default: 0) @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @option arguments [String] :conflicts What to do when the delete by query hits version conflicts? (options: abort, proceed) @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) @option arguments [String] :q Query in the Lucene query string syntax @option arguments [List] :routing A comma-separated list of specific routing values @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch) @option arguments [Time] :search_timeout Explicit timeout for each search request. Defaults to no timeout. @option arguments [Number] :size Deprecated, please use `max_docs` instead @option arguments [Number] :max_docs Maximum number of documents to process (default: all documents) @option arguments [List] :sort A comma-separated list of <field>:<direction> pairs @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field @option arguments [List] :_source_includes A list of fields to extract and return from the _source field @option arguments [Number] :terminate_after The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. @option arguments [List] :stats Specific 'tag' of the request for logging and statistical purposes @option arguments [Boolean] :version Specify whether to return document version as part of a hit @option arguments [Boolean] :request_cache Specify if request cache should be used for this request or not, defaults to index level setting @option arguments [Boolean] :refresh Should the effected indexes be refreshed? @option arguments [Time] :timeout Time each individual bulk request should wait for shards that are unavailable. @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) @option arguments [Number] :scroll_size Size on the scroll request powering the delete by query @option arguments [Boolean] :wait_for_completion Should the request should block until the delete by query is complete. @option arguments [Number] :requests_per_second The throttle for this request in sub-requests per second. -1 means no throttle. @option arguments [Number|string] :slices The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The search definition using the Query DSL (Required)

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/docs-delete-by-query.html

# File lib/elasticsearch/api/actions/delete_by_query.rb, line 68
def delete_by_query(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_POST
  path   = if _index && _type
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_delete_by_query"
           else
             "#{Utils.__listify(_index)}/_delete_by_query"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
delete_by_query_rethrottle(arguments = {}) click to toggle source

Changes the number of requests per second for a particular Delete By Query operation.

@option arguments [String] :task_id The task id to rethrottle @option arguments [Number] :requests_per_second The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. (Required) @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/docs-delete-by-query.html

# File lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb, line 29
def delete_by_query_rethrottle(arguments = {})
  raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _task_id = arguments.delete(:task_id)

  method = Elasticsearch::API::HTTP_POST
  path   = "_delete_by_query/#{Utils.__listify(_task_id)}/_rethrottle"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end
delete_script(arguments = {}) click to toggle source

Deletes a script.

@option arguments [String] :id Script ID @option arguments [Time] :timeout Explicit operation timeout @option arguments [Time] :master_timeout Specify timeout for connection to master @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/modules-scripting.html

# File lib/elasticsearch/api/actions/delete_script.rb, line 30
def delete_script(arguments = {})
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _id = arguments.delete(:id)

  method = Elasticsearch::API::HTTP_DELETE
  path   = "_scripts/#{Utils.__listify(_id)}"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end
exists(arguments = {}) click to toggle source

Returns information about whether a document exists in an index.

@option arguments [String] :id The document ID @option arguments [String] :index The name of the index @option arguments [String] :type The type of the document (use `_all` to fetch the first document matching the ID across all types) Deprecated @option arguments [List] :stored_fields A comma-separated list of stored fields to return in the response @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode @option arguments [Boolean] :refresh Refresh the shard containing the document before performing the operation @option arguments [String] :routing Specific routing value @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field @option arguments [List] :_source_includes A list of fields to extract and return from the _source field @option arguments [Number] :version Explicit version number for concurrency control @option arguments [String] :version_type Specific version type (options: internal, external, external_gte, force) @option arguments [Hash] :headers Custom HTTP headers

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/docs-get.html

# File lib/elasticsearch/api/actions/exists.rb, line 45
def exists(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _id = arguments.delete(:id)

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_HEAD
  path   = if _index && _type && _id
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}"
           else
             "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil

  Utils.__rescue_from_not_found do
    perform_request(method, path, params, body, headers).status == 200 ? true : false
  end
end
Also aliased as: exists?
exists?(arguments = {})
Alias for: exists
exists_source(arguments = {}) click to toggle source

Returns information about whether a document source exists in an index.

@option arguments [String] :id The document ID @option arguments [String] :index The name of the index @option arguments [String] :type The type of the document; deprecated and optional starting with 7.0 Deprecated @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode @option arguments [Boolean] :refresh Refresh the shard containing the document before performing the operation @option arguments [String] :routing Specific routing value @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field @option arguments [List] :_source_includes A list of fields to extract and return from the _source field @option arguments [Number] :version Explicit version number for concurrency control @option arguments [String] :version_type Specific version type (options: internal, external, external_gte, force) @option arguments [Hash] :headers Custom HTTP headers

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/docs-get.html

# File lib/elasticsearch/api/actions/exists_source.rb, line 44
def exists_source(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _id = arguments.delete(:id)

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_HEAD
  path   = if _index && _type && _id
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/_source"
           else
             "#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end
Also aliased as: exists_source?
exists_source?(arguments = {})
Alias for: exists_source
explain(arguments = {}) click to toggle source

Returns information about why a specific matches (or doesn't match) a query.

@option arguments [String] :id The document ID @option arguments [String] :index The name of the index @option arguments [String] :type The type of the document Deprecated @option arguments [Boolean] :analyze_wildcard Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false) @option arguments [String] :analyzer The analyzer for the query string query @option arguments [String] :default_operator The default operator for query string query (AND or OR) (options: AND, OR) @option arguments [String] :df The default field for query string query (default: _all) @option arguments [List] :stored_fields A comma-separated list of stored fields to return in the response @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) @option arguments [String] :q Query in the Lucene query string syntax @option arguments [String] :routing Specific routing value @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field @option arguments [List] :_source_includes A list of fields to extract and return from the _source field @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The query definition using the Query DSL

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/search-explain.html

# File lib/elasticsearch/api/actions/explain.rb, line 48
def explain(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _id = arguments.delete(:id)

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = if arguments[:body]
             Elasticsearch::API::HTTP_POST
           else
             Elasticsearch::API::HTTP_GET
           end

  path   = if _index && _type && _id
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/_explain"
           else
             "#{Utils.__listify(_index)}/_explain/#{Utils.__listify(_id)}"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
field_caps(arguments = {}) click to toggle source

Returns the information about the capabilities of fields among multiple indices.

@option arguments [List] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices @option arguments [List] :fields A comma-separated list of field names @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) @option arguments [Boolean] :include_unmapped Indicates whether unmapped fields should be included in the response. @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body An index filter specified with the Query DSL

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/search-field-caps.html

# File lib/elasticsearch/api/actions/field_caps.rb, line 34
def field_caps(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _index = arguments.delete(:index)

  method = if arguments[:body]
             Elasticsearch::API::HTTP_POST
           else
             Elasticsearch::API::HTTP_GET
           end

  path   = if _index
             "#{Utils.__listify(_index)}/_field_caps"
           else
             "_field_caps"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
get(arguments = {}) click to toggle source

Returns a document.

@option arguments [String] :id The document ID @option arguments [String] :index The name of the index @option arguments [String] :type The type of the document (use `_all` to fetch the first document matching the ID across all types) Deprecated @option arguments [List] :stored_fields A comma-separated list of stored fields to return in the response @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode @option arguments [Boolean] :refresh Refresh the shard containing the document before performing the operation @option arguments [String] :routing Specific routing value @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field @option arguments [List] :_source_includes A list of fields to extract and return from the _source field @option arguments [Number] :version Explicit version number for concurrency control @option arguments [String] :version_type Specific version type (options: internal, external, external_gte, force) @option arguments [Hash] :headers Custom HTTP headers

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/docs-get.html

# File lib/elasticsearch/api/actions/get.rb, line 45
def get(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _id = arguments.delete(:id)

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_GET
  path   = if _index && _type && _id
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}"
           else
             "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  if Array(arguments[:ignore]).include?(404)
    Utils.__rescue_from_not_found { perform_request(method, path, params, body, headers).body }
  else
    perform_request(method, path, params, body, headers).body
  end
end
get_script(arguments = {}) click to toggle source

Returns a script.

@option arguments [String] :id Script ID @option arguments [Time] :master_timeout Specify timeout for connection to master @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/modules-scripting.html

# File lib/elasticsearch/api/actions/get_script.rb, line 29
def get_script(arguments = {})
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _id = arguments.delete(:id)

  method = Elasticsearch::API::HTTP_GET
  path   = "_scripts/#{Utils.__listify(_id)}"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end
get_script_context(arguments = {}) click to toggle source

Returns all script contexts. This functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.

@option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/painless/7.15/painless-contexts.html

# File lib/elasticsearch/api/actions/get_script_context.rb, line 31
def get_script_context(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_GET
  path   = "_script_context"
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end
get_script_languages(arguments = {}) click to toggle source

Returns available script types, languages and contexts This functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.

@option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/modules-scripting.html

# File lib/elasticsearch/api/actions/get_script_languages.rb, line 31
def get_script_languages(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_GET
  path   = "_script_language"
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end
get_source(arguments = {}) click to toggle source

Returns the source of a document.

@option arguments [String] :id The document ID @option arguments [String] :index The name of the index @option arguments [String] :type The type of the document; deprecated and optional starting with 7.0 Deprecated @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode @option arguments [Boolean] :refresh Refresh the shard containing the document before performing the operation @option arguments [String] :routing Specific routing value @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field @option arguments [List] :_source_includes A list of fields to extract and return from the _source field @option arguments [Number] :version Explicit version number for concurrency control @option arguments [String] :version_type Specific version type (options: internal, external, external_gte, force) @option arguments [Hash] :headers Custom HTTP headers

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/docs-get.html

# File lib/elasticsearch/api/actions/get_source.rb, line 44
def get_source(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _id = arguments.delete(:id)

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_GET
  path   = if _index && _type && _id
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/_source"
           else
             "#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end
index(arguments = {}) click to toggle source

Creates or updates a document in an index.

@option arguments [String] :id Document ID @option arguments [String] :index The name of the index @option arguments [String] :type The type of the document Deprecated @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) @option arguments [String] :op_type Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create`for requests without an explicit document ID (options: index, create) @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. (options: true, false, wait_for) @option arguments [String] :routing Specific routing value @option arguments [Time] :timeout Explicit operation timeout @option arguments [Number] :version Explicit version number for concurrency control @option arguments [String] :version_type Specific version type (options: internal, external, external_gte) @option arguments [Number] :if_seq_no only perform the index operation if the last operation that has changed the document has the specified sequence number @option arguments [Number] :if_primary_term only perform the index operation if the last operation that has changed the document has the specified primary term @option arguments [String] :pipeline The pipeline id to preprocess incoming documents with @option arguments [Boolean] :require_alias When true, requires destination to be an alias. Default is false @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The document (Required)

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/docs-index_.html

# File lib/elasticsearch/api/actions/index.rb, line 47
def index(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _id = arguments.delete(:id)

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = _id ? Elasticsearch::API::HTTP_PUT : Elasticsearch::API::HTTP_POST
  path   = if _index && _type && _id
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}"
           elsif _index && _id
             "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
           elsif _index && _type
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}"
           else
             "#{Utils.__listify(_index)}/_doc"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
info(arguments = {}) click to toggle source

Returns basic information about the cluster.

@option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/index.html

# File lib/elasticsearch/api/actions/info.rb, line 27
def info(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_GET
  path   = ""
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end
mget(arguments = {}) click to toggle source

Allows to get multiple documents in one request.

@option arguments [String] :index The name of the index @option arguments [String] :type The type of the document Deprecated @option arguments [List] :stored_fields A comma-separated list of stored fields to return in the response @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode @option arguments [Boolean] :refresh Refresh the shard containing the document before performing the operation @option arguments [String] :routing Specific routing value @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field @option arguments [List] :_source_includes A list of fields to extract and return from the _source field @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body Document identifiers; can be either `docs` (containing full document information) or `ids` (when index and type is provided in the URL. (Required)

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/docs-multi-get.html

# File lib/elasticsearch/api/actions/mget.rb, line 43
def mget(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_POST
  path   = if _index && _type
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_mget"
           elsif _index
             "#{Utils.__listify(_index)}/_mget"
           else
             "_mget"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
msearch(arguments = {}) click to toggle source

Allows to execute several search operations in one request.

@option arguments [List] :index A comma-separated list of index names to use as default @option arguments [List] :type A comma-separated list of document types to use as default @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch) @option arguments [Number] :max_concurrent_searches Controls the maximum number of concurrent searches the multi search api will execute @option arguments [Boolean] :typed_keys Specify whether aggregation and suggester names should be prefixed by their respective types in the response @option arguments [Number] :pre_filter_shard_size A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. @option arguments [Number] :max_concurrent_shard_requests The number of concurrent shard requests each sub search executes concurrently per node. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests @option arguments [Boolean] :rest_total_hits_as_int Indicates whether hits.total should be rendered as an integer or an object in the rest search response @option arguments [Boolean] :ccs_minimize_roundtrips Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The request definitions (metadata-search request definition pairs), separated by newlines (Required)

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/search-multi-search.html

# File lib/elasticsearch/api/actions/msearch.rb, line 42
def msearch(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_POST
  path   = if _index && _type
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_msearch"
           elsif _index
             "#{Utils.__listify(_index)}/_msearch"
           else
             "_msearch"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  case
  when body.is_a?(Array) && body.any? { |d| d.has_key? :search }
    payload = body
              .inject([]) do |sum, item|
                meta = item
                data = meta.delete(:search)

                sum << meta
                sum << data
                sum
              end
              .map { |item| Elasticsearch::API.serializer.dump(item) }
    payload << "" unless payload.empty?
    payload = payload.join("\n")
  when body.is_a?(Array)
    payload = body.map { |d| d.is_a?(String) ? d : Elasticsearch::API.serializer.dump(d) }
    payload << "" unless payload.empty?
    payload = payload.join("\n")
  else
    payload = body
  end

  headers.merge!("Content-Type" => "application/x-ndjson")
  perform_request(method, path, params, payload, headers).body
end
msearch_template(arguments = {}) click to toggle source

Allows to execute several search template operations in one request.

@option arguments [List] :index A comma-separated list of index names to use as default @option arguments [List] :type A comma-separated list of document types to use as default @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch) @option arguments [Boolean] :typed_keys Specify whether aggregation and suggester names should be prefixed by their respective types in the response @option arguments [Number] :max_concurrent_searches Controls the maximum number of concurrent searches the multi search api will execute @option arguments [Boolean] :rest_total_hits_as_int Indicates whether hits.total should be rendered as an integer or an object in the rest search response @option arguments [Boolean] :ccs_minimize_roundtrips Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The request definitions (metadata-search request definition pairs), separated by newlines (Required)

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/search-multi-search.html

# File lib/elasticsearch/api/actions/msearch_template.rb, line 40
      def msearch_template(arguments = {})
        raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

        headers = arguments.delete(:headers) || {}

        arguments = arguments.clone

        _index = arguments.delete(:index)

        _type = arguments.delete(:type)

        method = Elasticsearch::API::HTTP_POST
        path   = if _index && _type
                   "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_msearch/template"
                 elsif _index
                   "#{Utils.__listify(_index)}/_msearch/template"
                 else
                   "_msearch/template"
                 end
        params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

        body = arguments[:body]
        case
        when body.is_a?(Array)
          payload = body.map { |d| d.is_a?(String) ? d : Elasticsearch::API.serializer.dump(d) }
          payload << "" unless payload.empty?
          payload = payload.join("
")
        else
          payload = body
        end

        headers.merge!("Content-Type" => "application/x-ndjson")
        perform_request(method, path, params, payload, headers).body
      end
mtermvectors(arguments = {}) click to toggle source

Returns multiple termvectors in one request.

@option arguments [String] :index The index in which the document resides. @option arguments [String] :type The type of the document. @option arguments [List] :ids A comma-separated list of documents ids. You must define ids as parameter or set “ids” or “docs” in the request body @option arguments [Boolean] :term_statistics Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”. @option arguments [Boolean] :field_statistics Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”. @option arguments [List] :fields A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body “params” or “docs”. @option arguments [Boolean] :offsets Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”. @option arguments [Boolean] :positions Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”. @option arguments [Boolean] :payloads Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”. @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body “params” or “docs”. @option arguments [String] :routing Specific routing value. Applies to all returned documents unless otherwise specified in body “params” or “docs”. @option arguments [Boolean] :realtime Specifies if requests are real-time as opposed to near-real-time (default: true). @option arguments [Number] :version Explicit version number for concurrency control @option arguments [String] :version_type Specific version type (options: internal, external, external_gte, force) @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation.

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/docs-multi-termvectors.html

# File lib/elasticsearch/api/actions/mtermvectors.rb, line 47
def mtermvectors(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone
  ids = arguments.delete(:ids)

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = if arguments[:body]
             Elasticsearch::API::HTTP_POST
           else
             Elasticsearch::API::HTTP_GET
           end

  path   = if _index && _type
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_mtermvectors"
           elsif _index
             "#{Utils.__listify(_index)}/_mtermvectors"
           else
             "_mtermvectors"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  if ids
    body = { :ids => ids }
  else
    body = arguments[:body]
  end
  perform_request(method, path, params, body, headers).body
end
open_point_in_time(arguments = {}) click to toggle source

Open a point in time that can be used in subsequent searches

@option arguments [List] :index A comma-separated list of index names to open point in time; use `_all` or empty string to perform the operation on all indices @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) @option arguments [String] :routing Specific routing value @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) @option arguments [String] :keep_alive Specific the time to live for the point in time @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/point-in-time-api.html

# File lib/elasticsearch/api/actions/open_point_in_time.rb, line 33
def open_point_in_time(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _index = arguments.delete(:index)

  method = Elasticsearch::API::HTTP_POST
  path   = "#{Utils.__listify(_index)}/_pit"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end
ping(arguments = {}) click to toggle source

Returns whether the cluster is running.

@option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/index.html

# File lib/elasticsearch/api/actions/ping.rb, line 27
def ping(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_HEAD
  path   = ""
  params = {}

  body = nil
  begin
    perform_request(method, path, params, body, headers).status == 200 ? true : false
  rescue Exception => e
    if e.class.to_s =~ /NotFound|ConnectionFailed/ || e.message =~ /Not *Found|404|ConnectionFailed/i
      false
    else
      raise e
    end
  end
end
put_script(arguments = {}) click to toggle source

Creates or updates a script.

@option arguments [String] :id Script ID @option arguments [String] :context Script context @option arguments [Time] :timeout Explicit operation timeout @option arguments [Time] :master_timeout Specify timeout for connection to master @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The document (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/modules-scripting.html

# File lib/elasticsearch/api/actions/put_script.rb, line 32
def put_script(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _id = arguments.delete(:id)

  _context = arguments.delete(:context)

  method = Elasticsearch::API::HTTP_PUT
  path   = if _id && _context
             "_scripts/#{Utils.__listify(_id)}/#{Utils.__listify(_context)}"
           else
             "_scripts/#{Utils.__listify(_id)}"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
rank_eval(arguments = {}) click to toggle source

Allows to evaluate the quality of ranked search results over a set of typical search queries This functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.

@option arguments [List] :index A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch) @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/search-rank-eval.html

# File lib/elasticsearch/api/actions/rank_eval.rb, line 37
def rank_eval(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _index = arguments.delete(:index)

  method = Elasticsearch::API::HTTP_POST
  path   = if _index
             "#{Utils.__listify(_index)}/_rank_eval"
           else
             "_rank_eval"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
reindex(arguments = {}) click to toggle source

Allows to copy documents from one index to another, optionally filtering the source documents by a query, changing the destination index settings, or fetching the documents from a remote cluster.

@option arguments [Boolean] :refresh Should the affected indexes be refreshed? @option arguments [Time] :timeout Time each individual bulk request should wait for shards that are unavailable. @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) @option arguments [Boolean] :wait_for_completion Should the request should block until the reindex is complete. @option arguments [Number] :requests_per_second The throttle to set on this request in sub-requests per second. -1 means no throttle. @option arguments [Time] :scroll Control how long to keep the search context alive @option arguments [Number|string] :slices The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. @option arguments [Number] :max_docs Maximum number of documents to process (default: all documents) @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The search definition using the Query DSL and the prototype for the index request. (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/docs-reindex.html

# File lib/elasticsearch/api/actions/reindex.rb, line 38
def reindex(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_POST
  path   = "_reindex"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
reindex_rethrottle(arguments = {}) click to toggle source

Changes the number of requests per second for a particular Reindex operation.

@option arguments [String] :task_id The task id to rethrottle @option arguments [Number] :requests_per_second The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. (Required) @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/docs-reindex.html

# File lib/elasticsearch/api/actions/reindex_rethrottle.rb, line 29
def reindex_rethrottle(arguments = {})
  raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _task_id = arguments.delete(:task_id)

  method = Elasticsearch::API::HTTP_POST
  path   = "_reindex/#{Utils.__listify(_task_id)}/_rethrottle"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end
render_search_template(arguments = {}) click to toggle source

Allows to use the Mustache language to pre-render a search definition.

@option arguments [String] :id The id of the stored search template @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The search definition template and its params

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/render-search-template-api.html

# File lib/elasticsearch/api/actions/render_search_template.rb, line 29
def render_search_template(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _id = arguments.delete(:id)

  method = if arguments[:body]
             Elasticsearch::API::HTTP_POST
           else
             Elasticsearch::API::HTTP_GET
           end

  path   = if _id
             "_render/template/#{Utils.__listify(_id)}"
           else
             "_render/template"
           end
  params = {}

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
scripts_painless_execute(arguments = {}) click to toggle source

Allows an arbitrary script to be executed and a result to be returned This functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.

@option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The script to execute

@see www.elastic.co/guide/en/elasticsearch/painless/7.15/painless-execute-api.html

# File lib/elasticsearch/api/actions/scripts_painless_execute.rb, line 32
def scripts_painless_execute(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = if arguments[:body]
             Elasticsearch::API::HTTP_POST
           else
             Elasticsearch::API::HTTP_GET
           end

  path   = "_scripts/painless/_execute"
  params = {}

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
scroll(arguments = {}) click to toggle source

Allows to retrieve a large numbers of results from a single search request.

@option arguments [String] :scroll_id The scroll ID Deprecated @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search @option arguments [Boolean] :rest_total_hits_as_int Indicates whether hits.total should be rendered as an integer or an object in the rest search response @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The scroll ID if not passed by URL or query parameter.

*Deprecation notice*: A scroll id can be quite large and should be specified as part of the body Deprecated since version 7.0.0

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/search-request-body.html#request-body-search-scroll

# File lib/elasticsearch/api/actions/scroll.rb, line 36
def scroll(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _scroll_id = arguments.delete(:scroll_id)

  method = if arguments[:body]
             Elasticsearch::API::HTTP_POST
           else
             Elasticsearch::API::HTTP_GET
           end

  path   = if _scroll_id
             "_search/scroll/#{Utils.__listify(_scroll_id)}"
           else
             "_search/scroll"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
search_mvt(arguments = {}) click to toggle source

Searches a vector tile for geospatial values. Returns results as a binary Mapbox vector tile. This functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.

@option arguments [List] :index Comma-separated list of data streams, indices, or aliases to search @option arguments [String] :field Field containing geospatial data to return @option arguments [Integer] :zoom Zoom level for the vector tile to search @option arguments [Integer] :x X coordinate for the vector tile to search @option arguments [Integer] :y Y coordinate for the vector tile to search @option arguments [Boolean] :exact_bounds If false, the meta layer's feature is the bounding box of the tile. If true, the meta layer's feature is a bounding box resulting from a `geo_bounds` aggregation. @option arguments [Integer] :extent Size, in pixels, of a side of the vector tile. @option arguments [Integer] :grid_precision Additional zoom levels available through the aggs layer. Accepts 0-8. @option arguments [String] :grid_type Determines the geometry type for features in the aggs layer. (options: grid, point) @option arguments [Integer] :size Maximum number of features to return in the hits layer. Accepts 0-10000. @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body Search request body.

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/search-vector-tile-api.html

# File lib/elasticsearch/api/actions/search_mvt.rb, line 42
def search_mvt(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
  raise ArgumentError, "Required argument 'field' missing" unless arguments[:field]
  raise ArgumentError, "Required argument 'zoom' missing" unless arguments[:zoom]
  raise ArgumentError, "Required argument 'x' missing" unless arguments[:x]
  raise ArgumentError, "Required argument 'y' missing" unless arguments[:y]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _index = arguments.delete(:index)

  _field = arguments.delete(:field)

  _zoom = arguments.delete(:zoom)

  _x = arguments.delete(:x)

  _y = arguments.delete(:y)

  method = Elasticsearch::API::HTTP_POST
  path   = "#{Utils.__listify(_index)}/_mvt/#{Utils.__listify(_field)}/#{Utils.__listify(_zoom)}/#{Utils.__listify(_x)}/#{Utils.__listify(_y)}"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
search_shards(arguments = {}) click to toggle source

Returns information about the indices and shards that a search request would be executed against.

@option arguments [List] :index A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) @option arguments [String] :routing Specific routing value @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/search-shards.html

# File lib/elasticsearch/api/actions/search_shards.rb, line 34
def search_shards(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _index = arguments.delete(:index)

  method = Elasticsearch::API::HTTP_GET
  path   = if _index
             "#{Utils.__listify(_index)}/_search_shards"
           else
             "_search_shards"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end
search_template(arguments = {}) click to toggle source

Allows to use the Mustache language to pre-render a search definition.

@option arguments [List] :index A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices @option arguments [List] :type A comma-separated list of document types to search; leave empty to perform the operation on all types @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) @option arguments [Boolean] :ignore_throttled Whether specified concrete, expanded or aliased indices should be ignored when throttled @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) @option arguments [List] :routing A comma-separated list of specific routing values @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch) @option arguments [Boolean] :explain Specify whether to return detailed information about score computation as part of a hit @option arguments [Boolean] :profile Specify whether to profile the query execution @option arguments [Boolean] :typed_keys Specify whether aggregation and suggester names should be prefixed by their respective types in the response @option arguments [Boolean] :rest_total_hits_as_int Indicates whether hits.total should be rendered as an integer or an object in the rest search response @option arguments [Boolean] :ccs_minimize_roundtrips Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The search definition template and its params (Required)

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/search-template.html

# File lib/elasticsearch/api/actions/search_template.rb, line 48
def search_template(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_POST
  path   = if _index && _type
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_search/template"
           elsif _index
             "#{Utils.__listify(_index)}/_search/template"
           else
             "_search/template"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
termvector(arguments = {}) click to toggle source

Deprecated: Use the plural version, {#termvectors}

# File lib/elasticsearch/api/actions/termvectors.rb, line 85
def termvector(arguments = {})
  termvectors(arguments.merge endpoint: '_termvector')
end
termvectors(arguments = {}) click to toggle source

Returns information and statistics about terms in the fields of a particular document.

@option arguments [String] :index The index in which the document resides. (Required) @option arguments [String] :id The id of the document, when not specified a doc param should be supplied. @option arguments [String] :type The type of the document. @option arguments [Boolean] :term_statistics Specifies if total term frequency and document frequency should be returned. @option arguments [Boolean] :field_statistics Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. @option arguments [List] :fields A comma-separated list of fields to return. @option arguments [Boolean] :offsets Specifies if term offsets should be returned. @option arguments [Boolean] :positions Specifies if term positions should be returned. @option arguments [Boolean] :payloads Specifies if term payloads should be returned. @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random). @option arguments [String] :routing Specific routing value. @option arguments [Boolean] :realtime Specifies if request is real-time as opposed to near-real-time (default: true). @option arguments [Number] :version Explicit version number for concurrency control @option arguments [String] :version_type Specific version type (options: internal, external, external_gte, force) @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body Define parameters and or supply a document to get termvectors for. See documentation.

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/docs-termvectors.html

# File lib/elasticsearch/api/actions/termvectors.rb, line 47
def termvectors(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _index = arguments.delete(:index)

  _id = arguments.delete(:id)

  _type = arguments.delete(:type)

  method = if arguments[:body]
             Elasticsearch::API::HTTP_POST
           else
             Elasticsearch::API::HTTP_GET
           end

  endpoint = arguments.delete(:endpoint) || '_termvectors'
  path   = if _index && _type && _id
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/#{endpoint}"
           elsif _index && _type
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{endpoint}"
           elsif _index && _id
             "#{Utils.__listify(_index)}/#{endpoint}/#{Utils.__listify(_id)}"
           else
             "#{Utils.__listify(_index)}/#{endpoint}"
           end

  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
update(arguments = {}) click to toggle source

Updates a document with a script or partial document.

@option arguments [String] :id Document ID @option arguments [String] :index The name of the index @option arguments [String] :type The type of the document Deprecated @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field @option arguments [List] :_source_includes A list of fields to extract and return from the _source field @option arguments [String] :lang The script language (default: painless) @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. (options: true, false, wait_for) @option arguments [Number] :retry_on_conflict Specify how many times should the operation be retried when a conflict occurs (default: 0) @option arguments [String] :routing Specific routing value @option arguments [Time] :timeout Explicit operation timeout @option arguments [Number] :if_seq_no only perform the update operation if the last operation that has changed the document has the specified sequence number @option arguments [Number] :if_primary_term only perform the update operation if the last operation that has changed the document has the specified primary term @option arguments [Boolean] :require_alias When true, requires destination is an alias. Default is false @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The request definition requires either `script` or partial `doc` (Required)

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/docs-update.html

# File lib/elasticsearch/api/actions/update.rb, line 48
def update(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _id = arguments.delete(:id)

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_POST
  path   = if _index && _type && _id
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/_update"
           else
             "#{Utils.__listify(_index)}/_update/#{Utils.__listify(_id)}"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  if Array(arguments[:ignore]).include?(404)
    Utils.__rescue_from_not_found { perform_request(method, path, params, body, headers).body }
  else
    perform_request(method, path, params, body, headers).body
  end
end
update_by_query(arguments = {}) click to toggle source

Performs an update on every document in the index without changing the source, for example to pick up a mapping change.

@option arguments [List] :index A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices (Required) @option arguments [List] :type A comma-separated list of document types to search; leave empty to perform the operation on all types @option arguments [String] :analyzer The analyzer to use for the query string @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed (default: false) @option arguments [String] :default_operator The default operator for query string query (AND or OR) (options: AND, OR) @option arguments [String] :df The field to use as default where no field prefix is given in the query string @option arguments [Number] :from Starting offset (default: 0) @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @option arguments [String] :conflicts What to do when the update by query hits version conflicts? (options: abort, proceed) @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored @option arguments [String] :pipeline Ingest pipeline to set on index requests made by this action. (default: none) @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) @option arguments [String] :q Query in the Lucene query string syntax @option arguments [List] :routing A comma-separated list of specific routing values @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch) @option arguments [Time] :search_timeout Explicit timeout for each search request. Defaults to no timeout. @option arguments [Number] :size Deprecated, please use `max_docs` instead @option arguments [Number] :max_docs Maximum number of documents to process (default: all documents) @option arguments [List] :sort A comma-separated list of <field>:<direction> pairs @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field @option arguments [List] :_source_includes A list of fields to extract and return from the _source field @option arguments [Number] :terminate_after The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. @option arguments [List] :stats Specific 'tag' of the request for logging and statistical purposes @option arguments [Boolean] :version Specify whether to return document version as part of a hit @option arguments [Boolean] :version_type Should the document increment the version number (internal) on hit or not (reindex) @option arguments [Boolean] :request_cache Specify if request cache should be used for this request or not, defaults to index level setting @option arguments [Boolean] :refresh Should the affected indexes be refreshed? @option arguments [Time] :timeout Time each individual bulk request should wait for shards that are unavailable. @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) @option arguments [Number] :scroll_size Size on the scroll request powering the update by query @option arguments [Boolean] :wait_for_completion Should the request should block until the update by query operation is complete. @option arguments [Number] :requests_per_second The throttle to set on this request in sub-requests per second. -1 means no throttle. @option arguments [Number|string] :slices The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The search definition using the Query DSL

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/docs-update-by-query.html

# File lib/elasticsearch/api/actions/update_by_query.rb, line 71
def update_by_query(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_POST
  path   = if _index && _type
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_update_by_query"
           else
             "#{Utils.__listify(_index)}/_update_by_query"
           end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
update_by_query_rethrottle(arguments = {}) click to toggle source

Changes the number of requests per second for a particular Update By Query operation.

@option arguments [String] :task_id The task id to rethrottle @option arguments [Number] :requests_per_second The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. (Required) @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.15/docs-update-by-query.html

# File lib/elasticsearch/api/actions/update_by_query_rethrottle.rb, line 29
def update_by_query_rethrottle(arguments = {})
  raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _task_id = arguments.delete(:task_id)

  method = Elasticsearch::API::HTTP_POST
  path   = "_update_by_query/#{Utils.__listify(_task_id)}/_rethrottle"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end