Module: OpenSearch::API::Actions

Defined in:
lib/opensearch/api/actions/get.rb,
lib/opensearch/api/actions/bulk.rb,
lib/opensearch/api/actions/info.rb,
lib/opensearch/api/actions/mget.rb,
lib/opensearch/api/actions/ping.rb,
lib/opensearch/api/actions/count.rb,
lib/opensearch/api/actions/index.rb,
lib/opensearch/api/actions/create.rb,
lib/opensearch/api/actions/delete.rb,
lib/opensearch/api/actions/exists.rb,
lib/opensearch/api/actions/scroll.rb,
lib/opensearch/api/actions/search.rb,
lib/opensearch/api/actions/update.rb,
lib/opensearch/api/actions/explain.rb,
lib/opensearch/api/actions/msearch.rb,
lib/opensearch/api/actions/reindex.rb,
lib/opensearch/api/actions/benchmark.rb,
lib/opensearch/api/actions/rank_eval.rb,
lib/opensearch/api/actions/create_pit.rb,
lib/opensearch/api/actions/delete_pit.rb,
lib/opensearch/api/actions/field_caps.rb,
lib/opensearch/api/actions/get_script.rb,
lib/opensearch/api/actions/get_source.rb,
lib/opensearch/api/actions/put_script.rb,
lib/opensearch/api/actions/termvectors.rb,
lib/opensearch/api/actions/clear_scroll.rb,
lib/opensearch/api/actions/get_all_pits.rb,
lib/opensearch/api/actions/mtermvectors.rb,
lib/opensearch/api/actions/delete_script.rb,
lib/opensearch/api/actions/exists_source.rb,
lib/opensearch/api/actions/search_shards.rb,
lib/opensearch/api/actions/abort_benchmark.rb,
lib/opensearch/api/actions/delete_all_pits.rb,
lib/opensearch/api/actions/delete_by_query.rb,
lib/opensearch/api/actions/params_registry.rb,
lib/opensearch/api/actions/search_template.rb,
lib/opensearch/api/actions/update_by_query.rb,
lib/opensearch/api/actions/msearch_template.rb,
lib/opensearch/api/actions/get_script_context.rb,
lib/opensearch/api/actions/reindex_rethrottle.rb,
lib/opensearch/api/actions/delete_by_rethrottle.rb,
lib/opensearch/api/actions/get_script_languages.rb,
lib/opensearch/api/actions/render_search_template.rb,
lib/opensearch/api/actions/scripts_painless_execute.rb,
lib/opensearch/api/actions/delete_by_query_rethrottle.rb,
lib/opensearch/api/actions/update_by_query_rethrottle.rb

Defined Under Namespace

Modules: ParamsRegistry

Instance Method Summary collapse

Instance Method Details

#abort_benchmark(arguments = {}) ⇒ Object

Abort a running benchmark

Examples:


client.abort_benchmark name: 'my_benchmark'

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :name (String)

    A benchmark name



39
40
41
42
43
44
45
46
# File 'lib/opensearch/api/actions/abort_benchmark.rb', line 39

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 = {}) ⇒ Object

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

Examples:

Return statistics for a single query


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

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*' } } }
      ]
    }
  ]
}

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :index (List)

    A comma-separated list of index names; use ‘_all` or empty string to perform the operation on all indices

  • :body (Hash)

    The search definition using the Query DSL

  • :verbose (Boolean)

    Specify whether to return verbose statistics about each iteration (default: false)



73
74
75
76
77
78
79
80
# File 'lib/opensearch/api/actions/benchmark.rb', line 73

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 = {}) ⇒ Object

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

or the conveniency “combined” format can be passed, refer to OpenSearch::API::Utils.__bulkify documentation.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :index (String)

    Default index for items which don’t provide one

  • :wait_for_active_shards (String)

    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)

  • :refresh (String)

    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)

  • :routing (String)

    Specific routing value

  • :timeout (Time)

    Explicit operation timeout

  • :_source (List)

    True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request

  • :_source_excludes (List)

    Default list of fields to exclude from the returned _source field, can be overridden on each sub-request

  • :_source_includes (List)

    Default list of fields to extract and return from the _source field, can be overridden on each sub-request

  • :pipeline (String)

    The pipeline id to preprocess incoming documents with

  • :require_alias (Boolean)

    Sets require_alias for all incoming documents. Defaults to unset (false)

  • :headers (Hash)

    Custom HTTP headers

  • :body (String|Array)

    The operation definition and data (action-data pairs), separated by newlines. Array of Strings, Header/Data pairs,

Raises:

  • (ArgumentError)


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/opensearch/api/actions/bulk.rb', line 47

def bulk(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

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

  arguments = arguments.clone

  _index = arguments.delete(:index)

  method = OpenSearch::API::HTTP_POST
  path   = if _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 = OpenSearch::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 = {}) ⇒ Object

Explicitly clears the search context for a scroll.

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :scroll_id (List)

    A comma-separated list of scroll IDs to clear Deprecated

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/opensearch/api/actions/clear_scroll.rb', line 42

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

  arguments = arguments.clone

  _scroll_id = arguments.delete(:scroll_id)

  method = OpenSearch::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

#count(arguments = {}) ⇒ Object

Returns number of documents matching a query.

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :index (List)

    A comma-separated list of indices to restrict the results

  • :ignore_unavailable (Boolean)

    Whether specified concrete indices should be ignored when unavailable (missing or closed)

  • :ignore_throttled (Boolean)

    Whether specified concrete, expanded or aliased indices should be ignored when throttled

  • :allow_no_indices (Boolean)

    Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes ‘_all` string or when no indices have been specified)

  • :expand_wildcards (String)

    Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)

  • :min_score (Number)

    Include only documents with a specific ‘_score` value in the result

  • :preference (String)

    Specify the node or shard the operation should be performed on (default: random)

  • :routing (List)

    A comma-separated list of specific routing values

  • :q (String)

    Query in the Lucene query string syntax

  • :analyzer (String)

    The analyzer to use for the query string

  • :analyze_wildcard (Boolean)

    Specify whether wildcard and prefix queries should be analyzed (default: false)

  • :default_operator (String)

    The default operator for query string query (AND or OR) (options: AND, OR)

  • :df (String)

    The field to use as default where no field prefix is given in the query string

  • :lenient (Boolean)

    Specify whether format-based query failures (such as providing text to a numeric field) should be ignored

  • :terminate_after (Number)

    The maximum count for each shard, upon reaching which the query execution will terminate early

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    A query to restrict the results specified with the Query DSL (optional)



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/opensearch/api/actions/count.rb', line 56

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

  arguments = arguments.clone

  _index = arguments.delete(:index)

  method = OpenSearch::API::HTTP_POST
  path   = if _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 = {}) ⇒ Object

Creates a new document in the index.

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

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    Document ID

  • :index (String)

    The name of the index

  • :wait_for_active_shards (String)

    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)

  • :refresh (String)

    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)

  • :routing (String)

    Specific routing value

  • :timeout (Time)

    Explicit operation timeout

  • :version (Number)

    Explicit version number for concurrency control

  • :version_type (String)

    Specific version type (options: internal, external, external_gte)

  • :pipeline (String)

    The pipeline id to preprocess incoming documents with

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The document (Required)



51
52
53
54
55
56
57
# File 'lib/opensearch/api/actions/create.rb', line 51

def create(arguments = {})
  if arguments[:id]
    index arguments.update op_type: 'create'
  else
    index arguments
  end
end

#create_pit(arguments = {}) ⇒ Object

Creates a point in time.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :index (String)

    The name(s) of the target index(es) for the PIT. May contain a comma-separated list or a wildcard index pattern. (required)

  • :keep_alive (String)

    The amount of time to keep the PIT. (required)

  • :preference (String)

    The node or the shard used to perform the search. (default: random)

  • :routing (String)

    Specifies to route search requests to a specific shard.

  • :expand_wildcards (String)

    The type of index that can match the wildcard pattern. Supports comma-separated values. (default: open)

  • :allow_partial_pit_creation (String)

    Specifies whether to create a PIT with partial failures. (default: false)

Raises:

  • (ArgumentError)


21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/opensearch/api/actions/create_pit.rb', line 21

def create_pit(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
  raise ArgumentError, "Required argument 'keep_alive' missing" unless arguments[:keep_alive]

  arguments = arguments.clone
  _index = arguments.delete(:index)

  method = OpenSearch::API::HTTP_POST
  path = "#{Utils.__listify(_index)}/_search/point_in_time"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
  body = nil

  perform_request(method, path, params, body).body
end

#delete(arguments = {}) ⇒ Object

Removes a document from the index.

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    The document ID

  • :index (String)

    The name of the index

  • :wait_for_active_shards (String)

    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)

  • :refresh (String)

    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)

  • :routing (String)

    Specific routing value

  • :timeout (Time)

    Explicit operation timeout

  • :if_seq_no (Number)

    only perform the delete operation if the last operation that has changed the document has the specified sequence number

  • :if_primary_term (Number)

    only perform the delete operation if the last operation that has changed the document has the specified primary term

  • :version (Number)

    Explicit version number for concurrency control

  • :version_type (String)

    Specific version type (options: internal, external, external_gte, force)

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/opensearch/api/actions/delete.rb', line 50

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)

  method = OpenSearch::API::HTTP_DELETE
  path   = "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
  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_all_pits(arguments = {}) ⇒ Object

Deletes all PITs.



14
15
16
17
18
19
20
21
# File 'lib/opensearch/api/actions/delete_all_pits.rb', line 14

def delete_all_pits(arguments = {})
  method = OpenSearch::API::HTTP_DELETE
  path = "_search/point_in_time/_all"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
  body = nil

  perform_request(method, path, params, body).body
end

#delete_by_query(arguments = {}) ⇒ Object

Deletes documents matching the provided query.

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :index (List)

    A comma-separated list of index names to search; use ‘_all` or empty string to perform the operation on all indices (Required)

  • :analyzer (String)

    The analyzer to use for the query string

  • :analyze_wildcard (Boolean)

    Specify whether wildcard and prefix queries should be analyzed (default: false)

  • :default_operator (String)

    The default operator for query string query (AND or OR) (options: AND, OR)

  • :df (String)

    The field to use as default where no field prefix is given in the query string

  • :from (Number)

    Starting offset (default: 0)

  • :ignore_unavailable (Boolean)

    Whether specified concrete indices should be ignored when unavailable (missing or closed)

  • :allow_no_indices (Boolean)

    Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes ‘_all` string or when no indices have been specified)

  • :conflicts (String)

    What to do when the delete by query hits version conflicts? (options: abort, proceed)

  • :expand_wildcards (String)

    Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)

  • :lenient (Boolean)

    Specify whether format-based query failures (such as providing text to a numeric field) should be ignored

  • :preference (String)

    Specify the node or shard the operation should be performed on (default: random)

  • :q (String)

    Query in the Lucene query string syntax

  • :routing (List)

    A comma-separated list of specific routing values

  • :scroll (Time)

    Specify how long a consistent view of the index should be maintained for scrolled search

  • :search_type (String)

    Search operation type (options: query_then_fetch, dfs_query_then_fetch)

  • :search_timeout (Time)

    Explicit timeout for each search request. Defaults to no timeout.

  • :size (Number)

    Deprecated, please use ‘max_docs` instead

  • :max_docs (Number)

    Maximum number of documents to process (default: all documents)

  • :sort (List)

    A comma-separated list of <field>:<direction> pairs

  • :_source (List)

    True or false to return the _source field or not, or a list of fields to return

  • :_source_excludes (List)

    A list of fields to exclude from the returned _source field

  • :_source_includes (List)

    A list of fields to extract and return from the _source field

  • :terminate_after (Number)

    The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.

  • :stats (List)

    Specific ‘tag’ of the request for logging and statistical purposes

  • :version (Boolean)

    Specify whether to return document version as part of a hit

  • :request_cache (Boolean)

    Specify if request cache should be used for this request or not, defaults to index level setting

  • :refresh (Boolean)

    Should the effected indexes be refreshed?

  • :timeout (Time)

    Time each individual bulk request should wait for shards that are unavailable.

  • :wait_for_active_shards (String)

    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)

  • :scroll_size (Number)

    Size on the scroll request powering the delete by query

  • :wait_for_completion (Boolean)

    Should the request should block until the delete by query is complete.

  • :requests_per_second (Number)

    The throttle for this request in sub-requests per second. -1 means no throttle.

  • :slices (Number|string)

    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`.

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The search definition using the Query DSL (Required)

Raises:

  • (ArgumentError)


75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/opensearch/api/actions/delete_by_query.rb', line 75

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)

  method = OpenSearch::API::HTTP_POST
  path   = "#{Utils.__listify(_index)}/_delete_by_query"
  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 = {}) ⇒ Object

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :task_id (String)

    The task id to rethrottle

  • :requests_per_second (Number)

    The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. (Required)

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)


36
37
38
39
40
41
42
43
44
45
# File 'lib/opensearch/api/actions/delete_by_rethrottle.rb', line 36

def delete_by_query_rethrottle(arguments = {})
  raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id]

  method = OpenSearch::API::HTTP_POST
  path   = "_delete_by_query/#{arguments[:task_id]}/_rethrottle"
  params = OpenSearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
  body   = nil

  perform_request(method, path, params, body).body
end

#delete_pit(arguments = {}) ⇒ Object

Deletes one or several PITs.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • body: (Hash)

    Must include ‘pit_id`, which is an array of PIT IDs to be deleted. (required)

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
24
25
# File 'lib/opensearch/api/actions/delete_pit.rb', line 16

def delete_pit(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  method = OpenSearch::API::HTTP_DELETE
  path = "_search/point_in_time"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
  body = arguments[:body]

  perform_request(method, path, params, body).body
end

#delete_script(arguments = {}) ⇒ Object

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :cluster_manager_timeout (Time)

    Specify timeout for connection to cluster_manager

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/opensearch/api/actions/delete_script.rb', line 39

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 = OpenSearch::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 = {}) ⇒ Object Also known as: exists?

Returns information about whether a document exists in an index.

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    The document ID

  • :index (String)

    The name of the index

  • :stored_fields (List)

    A comma-separated list of stored fields to return in the response

  • :preference (String)

    Specify the node or shard the operation should be performed on (default: random)

  • :realtime (Boolean)

    Specify whether to perform the operation in realtime or search mode

  • :refresh (Boolean)

    Refresh the shard containing the document before performing the operation

  • :routing (String)

    Specific routing value

  • :_source (List)

    True or false to return the _source field or not, or a list of fields to return

  • :_source_excludes (List)

    A list of fields to exclude from the returned _source field

  • :_source_includes (List)

    A list of fields to extract and return from the _source field

  • :version (Number)

    Explicit version number for concurrency control

  • :version_type (String)

    Specific version type (options: internal, external, external_gte, force)

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/opensearch/api/actions/exists.rb', line 52

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)

  method = OpenSearch::API::HTTP_HEAD
  path   = "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
  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

#exists_source(arguments = {}) ⇒ Object Also known as: exists_source?

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

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    The document ID

  • :index (String)

    The name of the index

  • :preference (String)

    Specify the node or shard the operation should be performed on (default: random)

  • :realtime (Boolean)

    Specify whether to perform the operation in realtime or search mode

  • :refresh (Boolean)

    Refresh the shard containing the document before performing the operation

  • :routing (String)

    Specific routing value

  • :_source (List)

    True or false to return the _source field or not, or a list of fields to return

  • :_source_excludes (List)

    A list of fields to exclude from the returned _source field

  • :_source_includes (List)

    A list of fields to extract and return from the _source field

  • :version (Number)

    Explicit version number for concurrency control

  • :version_type (String)

    Specific version type (options: internal, external, external_gte, force)

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)


51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/opensearch/api/actions/exists_source.rb', line 51

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)

  method = OpenSearch::API::HTTP_HEAD
  path   = "#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#explain(arguments = {}) ⇒ Object

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

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    The document ID

  • :index (String)

    The name of the index

  • :analyze_wildcard (Boolean)

    Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false)

  • :analyzer (String)

    The analyzer for the query string query

  • :default_operator (String)

    The default operator for query string query (AND or OR) (options: AND, OR)

  • :df (String)

    The default field for query string query (default: _all)

  • :stored_fields (List)

    A comma-separated list of stored fields to return in the response

  • :lenient (Boolean)

    Specify whether format-based query failures (such as providing text to a numeric field) should be ignored

  • :preference (String)

    Specify the node or shard the operation should be performed on (default: random)

  • :q (String)

    Query in the Lucene query string syntax

  • :routing (String)

    Specific routing value

  • :_source (List)

    True or false to return the _source field or not, or a list of fields to return

  • :_source_excludes (List)

    A list of fields to exclude from the returned _source field

  • :_source_includes (List)

    A list of fields to extract and return from the _source field

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The query definition using the Query DSL

Raises:

  • (ArgumentError)


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/opensearch/api/actions/explain.rb', line 55

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)

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

  path = "#{Utils.__listify(_index)}/_explain/#{Utils.__listify(_id)}"
  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 = {}) ⇒ Object

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :index (List)

    A comma-separated list of index names; use ‘_all` or empty string to perform the operation on all indices

  • :fields (List)

    A comma-separated list of field names

  • :ignore_unavailable (Boolean)

    Whether specified concrete indices should be ignored when unavailable (missing or closed)

  • :allow_no_indices (Boolean)

    Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes ‘_all` string or when no indices have been specified)

  • :expand_wildcards (String)

    Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)

  • :include_unmapped (Boolean)

    Indicates whether unmapped fields should be included in the response.

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    An index filter specified with the Query DSL



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/opensearch/api/actions/field_caps.rb', line 42

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

  arguments = arguments.clone

  _index = arguments.delete(:index)

  method = if arguments[:body]
             OpenSearch::API::HTTP_POST
           else
             OpenSearch::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 = {}) ⇒ Object

Returns a document.

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    The document ID

  • :index (String)

    The name of the index

  • :stored_fields (List)

    A comma-separated list of stored fields to return in the response

  • :preference (String)

    Specify the node or shard the operation should be performed on (default: random)

  • :realtime (Boolean)

    Specify whether to perform the operation in realtime or search mode

  • :refresh (Boolean)

    Refresh the shard containing the document before performing the operation

  • :routing (String)

    Specific routing value

  • :_source (List)

    True or false to return the _source field or not, or a list of fields to return

  • :_source_excludes (List)

    A list of fields to exclude from the returned _source field

  • :_source_includes (List)

    A list of fields to extract and return from the _source field

  • :version (Number)

    Explicit version number for concurrency control

  • :version_type (String)

    Specific version type (options: internal, external, external_gte, force)

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/opensearch/api/actions/get.rb', line 52

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)

  method = OpenSearch::API::HTTP_GET
  path   = "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
  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_all_pits(arguments = {}) ⇒ Object

Gets all PITs.



14
15
16
17
18
19
20
21
# File 'lib/opensearch/api/actions/get_all_pits.rb', line 14

def get_all_pits(arguments = {})
  method = OpenSearch::API::HTTP_GET
  path = "_search/point_in_time/_all"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
  body = nil

  perform_request(method, path, params, body).body
end

#get_script(arguments = {}) ⇒ Object

Returns a script.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    Script ID

  • :master_timeout (Time) — default: DEPRECATED: use cluster_manager_timeout instead

    Specify timeout for connection to master

  • :cluster_manager_timeout (Time)

    Specify timeout for connection to cluster_manager

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/opensearch/api/actions/get_script.rb', line 38

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 = OpenSearch::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 = {}) ⇒ Object

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :headers (Hash)

    Custom HTTP headers



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/opensearch/api/actions/get_script_context.rb', line 39

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

  arguments = arguments.clone

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

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

#get_script_languages(arguments = {}) ⇒ Object

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :headers (Hash)

    Custom HTTP headers



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/opensearch/api/actions/get_script_languages.rb', line 39

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

  arguments = arguments.clone

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

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

#get_source(arguments = {}) ⇒ Object

Returns the source of a document.

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    The document ID

  • :index (String)

    The name of the index

  • :preference (String)

    Specify the node or shard the operation should be performed on (default: random)

  • :realtime (Boolean)

    Specify whether to perform the operation in realtime or search mode

  • :refresh (Boolean)

    Refresh the shard containing the document before performing the operation

  • :routing (String)

    Specific routing value

  • :_source (List)

    True or false to return the _source field or not, or a list of fields to return

  • :_source_excludes (List)

    A list of fields to exclude from the returned _source field

  • :_source_includes (List)

    A list of fields to extract and return from the _source field

  • :version (Number)

    Explicit version number for concurrency control

  • :version_type (String)

    Specific version type (options: internal, external, external_gte, force)

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)


51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/opensearch/api/actions/get_source.rb', line 51

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)

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

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

#index(arguments = {}) ⇒ Object

Creates or updates a document in an index.

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    Document ID

  • :index (String)

    The name of the index

  • :wait_for_active_shards (String)

    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)

  • :op_type (String)

    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)

  • :refresh (String)

    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)

  • :routing (String)

    Specific routing value

  • :timeout (Time)

    Explicit operation timeout

  • :version (Number)

    Explicit version number for concurrency control

  • :version_type (String)

    Specific version type (options: internal, external, external_gte)

  • :if_seq_no (Number)

    only perform the index operation if the last operation that has changed the document has the specified sequence number

  • :if_primary_term (Number)

    only perform the index operation if the last operation that has changed the document has the specified primary term

  • :pipeline (String)

    The pipeline id to preprocess incoming documents with

  • :require_alias (Boolean)

    When true, requires destination to be an alias. Default is false

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The document (Required)

Raises:

  • (ArgumentError)


54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/opensearch/api/actions/index.rb', line 54

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)

  method = _id ? OpenSearch::API::HTTP_PUT : OpenSearch::API::HTTP_POST
  path   = if _index && _id
             "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
           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 = {}) ⇒ Object

Returns basic information about the cluster.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :headers (Hash)

    Custom HTTP headers



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/opensearch/api/actions/info.rb', line 35

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

  arguments = arguments.clone

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

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

#mget(arguments = {}) ⇒ Object

Allows to get multiple documents in one request.

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :index (String)

    The name of the index

  • :stored_fields (List)

    A comma-separated list of stored fields to return in the response

  • :preference (String)

    Specify the node or shard the operation should be performed on (default: random)

  • :realtime (Boolean)

    Specify whether to perform the operation in realtime or search mode

  • :refresh (Boolean)

    Refresh the shard containing the document before performing the operation

  • :routing (String)

    Specific routing value

  • :_source (List)

    True or false to return the _source field or not, or a list of fields to return

  • :_source_excludes (List)

    A list of fields to exclude from the returned _source field

  • :_source_includes (List)

    A list of fields to extract and return from the _source field

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    Document identifiers; can be either ‘docs` (containing full document information) or `ids` (when index is provided in the URL. (Required)

Raises:

  • (ArgumentError)


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/opensearch/api/actions/mget.rb', line 50

def mget(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

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

  arguments = arguments.clone

  _index = arguments.delete(:index)

  method = OpenSearch::API::HTTP_POST
  path   = if _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 = {}) ⇒ Object

Allows to execute several search operations in one request.

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :index (List)

    A comma-separated list of index names to use as default

  • :search_type (String)

    Search operation type (options: query_then_fetch, dfs_query_then_fetch)

  • :max_concurrent_searches (Number)

    Controls the maximum number of concurrent searches the multi search api will execute

  • :typed_keys (Boolean)

    Specify whether aggregation and suggester names should be prefixed by their respective types in the response

  • :pre_filter_shard_size (Number)

    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.

  • :max_concurrent_shard_requests (Number)

    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

  • :rest_total_hits_as_int (Boolean)

    Indicates whether hits.total should be rendered as an integer or an object in the rest search response

  • :ccs_minimize_roundtrips (Boolean)

    Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The request definitions (metadata-search request definition pairs), separated by newlines (Required)

Raises:

  • (ArgumentError)


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/opensearch/api/actions/msearch.rb', line 49

def msearch(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

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

  arguments = arguments.clone

  _index = arguments.delete(:index)

  method = OpenSearch::API::HTTP_POST
  path   = if _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| OpenSearch::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 : OpenSearch::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 = {}) ⇒ Object

Allows to execute several search template operations in one request.

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :index (List)

    A comma-separated list of index names to use as default

  • :search_type (String)

    Search operation type (options: query_then_fetch, dfs_query_then_fetch)

  • :typed_keys (Boolean)

    Specify whether aggregation and suggester names should be prefixed by their respective types in the response

  • :max_concurrent_searches (Number)

    Controls the maximum number of concurrent searches the multi search api will execute

  • :rest_total_hits_as_int (Boolean)

    Indicates whether hits.total should be rendered as an integer or an object in the rest search response

  • :ccs_minimize_roundtrips (Boolean)

    Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The request definitions (metadata-search request definition pairs), separated by newlines (Required)

Raises:

  • (ArgumentError)


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/opensearch/api/actions/msearch_template.rb', line 47

def msearch_template(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

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

  arguments = arguments.clone

  _index = arguments.delete(:index)

  method = OpenSearch::API::HTTP_POST
  path   = if _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 : OpenSearch::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 = {}) ⇒ Object

Returns multiple termvectors in one request.

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :index (String)

    The index in which the document resides.

  • :ids (List)

    A comma-separated list of documents ids. You must define ids as parameter or set “ids” or “docs” in the request body

  • :term_statistics (Boolean)

    Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”.

  • :field_statistics (Boolean)

    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”.

  • :fields (List)

    A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body “params” or “docs”.

  • :offsets (Boolean)

    Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”.

  • :positions (Boolean)

    Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”.

  • :payloads (Boolean)

    Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”.

  • :preference (String)

    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”.

  • :routing (String)

    Specific routing value. Applies to all returned documents unless otherwise specified in body “params” or “docs”.

  • :realtime (Boolean)

    Specifies if requests are real-time as opposed to near-real-time (default: true).

  • :version (Number)

    Explicit version number for concurrency control

  • :version_type (String)

    Specific version type (options: internal, external, external_gte, force)

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/opensearch/api/actions/mtermvectors.rb', line 54

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

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

  _index = arguments.delete(:index)

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

  path = if _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

#ping(arguments = {}) ⇒ Object

Returns whether the cluster is running.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :headers (Hash)

    Custom HTTP headers



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/opensearch/api/actions/ping.rb', line 35

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

  arguments = arguments.clone

  method = OpenSearch::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 = {}) ⇒ Object

Creates or updates a script.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    Script ID

  • :context (String)

    Script context

  • :timeout (Time)

    Explicit operation timeout

  • :master_timeout (Time) — default: DEPRECATED: use cluster_manager_timeout instead

    Specify timeout for connection to master

  • :cluster_manager_timeout (Time)

    Specify timeout for connection to cluster_manager

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The document (Required)

Raises:

  • (ArgumentError)


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/opensearch/api/actions/put_script.rb', line 41

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 = OpenSearch::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 = {}) ⇒ Object

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. OpenSearch will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :index (List)

    A comma-separated list of index names to search; use ‘_all` or empty string to perform the operation on all indices

  • :ignore_unavailable (Boolean)

    Whether specified concrete indices should be ignored when unavailable (missing or closed)

  • :allow_no_indices (Boolean)

    Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes ‘_all` string or when no indices have been specified)

  • :expand_wildcards (String)

    Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)

  • :search_type (String)

    Search operation type (options: query_then_fetch, dfs_query_then_fetch)

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. (Required)

Raises:

  • (ArgumentError)


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/opensearch/api/actions/rank_eval.rb', line 45

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 = OpenSearch::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 = {}) ⇒ Object

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.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :refresh (Boolean)

    Should the affected indexes be refreshed?

  • :timeout (Time)

    Time each individual bulk request should wait for shards that are unavailable.

  • :wait_for_active_shards (String)

    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)

  • :wait_for_completion (Boolean)

    Should the request should block until the reindex is complete.

  • :requests_per_second (Number)

    The throttle to set on this request in sub-requests per second. -1 means no throttle.

  • :scroll (Time)

    Control how long to keep the search context alive

  • :slices (Number|string)

    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`.

  • :max_docs (Number)

    Maximum number of documents to process (default: all documents)

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The search definition using the Query DSL and the prototype for the index request. (Required)

Raises:

  • (ArgumentError)


46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/opensearch/api/actions/reindex.rb', line 46

def reindex(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

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

  arguments = arguments.clone

  method = OpenSearch::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 = {}) ⇒ Object

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :task_id (String)

    The task id to rethrottle

  • :requests_per_second (Number)

    The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. (Required)

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/opensearch/api/actions/reindex_rethrottle.rb', line 37

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 = OpenSearch::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 = {}) ⇒ Object

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    The id of the stored search template

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The search definition template and its params



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/opensearch/api/actions/render_search_template.rb', line 37

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

  arguments = arguments.clone

  _id = arguments.delete(:id)

  method = if arguments[:body]
             OpenSearch::API::HTTP_POST
           else
             OpenSearch::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 = {}) ⇒ Object

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. OpenSearch will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The script to execute



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/opensearch/api/actions/scripts_painless_execute.rb', line 40

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

  arguments = arguments.clone

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

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

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end

#scroll(arguments = {}) ⇒ Object

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

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :scroll_id (String)

    The scroll ID Deprecated

  • :scroll (Time)

    Specify how long a consistent view of the index should be maintained for scrolled search

  • :rest_total_hits_as_int (Boolean)

    Indicates whether hits.total should be rendered as an integer or an object in the rest search response

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The scroll ID if not passed by URL or query parameter.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/opensearch/api/actions/scroll.rb', line 44

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

  arguments = arguments.clone

  _scroll_id = arguments.delete(:scroll_id)

  method = if arguments[:body]
             OpenSearch::API::HTTP_POST
           else
             OpenSearch::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(arguments = {}) ⇒ Object

Returns results matching a query.

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :index (List)

    A comma-separated list of index names to search; use ‘_all` or empty string to perform the operation on all indices

  • :analyzer (String)

    The analyzer to use for the query string

  • :analyze_wildcard (Boolean)

    Specify whether wildcard and prefix queries should be analyzed (default: false)

  • :ccs_minimize_roundtrips (Boolean)

    Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution

  • :default_operator (String)

    The default operator for query string query (AND or OR) (options: AND, OR)

  • :df (String)

    The field to use as default where no field prefix is given in the query string

  • :explain (Boolean)

    Specify whether to return detailed information about score computation as part of a hit

  • :stored_fields (List)

    A comma-separated list of stored fields to return as part of a hit

  • :docvalue_fields (List)

    A comma-separated list of fields to return as the docvalue representation of a field for each hit

  • :from (Number)

    Starting offset (default: 0)

  • :ignore_unavailable (Boolean)

    Whether specified concrete indices should be ignored when unavailable (missing or closed)

  • :ignore_throttled (Boolean)

    Whether specified concrete, expanded or aliased indices should be ignored when throttled

  • :allow_no_indices (Boolean)

    Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes ‘_all` string or when no indices have been specified)

  • :expand_wildcards (String)

    Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)

  • :lenient (Boolean)

    Specify whether format-based query failures (such as providing text to a numeric field) should be ignored

  • :preference (String)

    Specify the node or shard the operation should be performed on (default: random)

  • :q (String)

    Query in the Lucene query string syntax

  • :routing (List)

    A comma-separated list of specific routing values

  • :scroll (Time)

    Specify how long a consistent view of the index should be maintained for scrolled search

  • :search_type (String)

    Search operation type (options: query_then_fetch, dfs_query_then_fetch)

  • :size (Number)

    Number of hits to return (default: 10)

  • :sort (List)

    A comma-separated list of <field>:<direction> pairs

  • :_source (List)

    True or false to return the _source field or not, or a list of fields to return

  • :_source_excludes (List)

    A list of fields to exclude from the returned _source field

  • :_source_includes (List)

    A list of fields to extract and return from the _source field

  • :terminate_after (Number)

    The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.

  • :stats (List)

    Specific ‘tag’ of the request for logging and statistical purposes

  • :suggest_field (String)

    Specify which field to use for suggestions

  • :suggest_mode (String)

    Specify suggest mode (options: missing, popular, always)

  • :suggest_size (Number)

    How many suggestions to return in response

  • :suggest_text (String)

    The source text for which the suggestions should be returned

  • :timeout (Time)

    Explicit operation timeout

  • :track_scores (Boolean)

    Whether to calculate and return scores even if they are not used for sorting

  • :track_total_hits (Boolean)

    Indicate if the number of documents that match the query should be tracked

  • :allow_partial_search_results (Boolean)

    Indicate if an error should be returned if there is a partial search failure or timeout

  • :typed_keys (Boolean)

    Specify whether aggregation and suggester names should be prefixed by their respective types in the response

  • :version (Boolean)

    Specify whether to return document version as part of a hit

  • :seq_no_primary_term (Boolean)

    Specify whether to return sequence number and primary term of the last modification of each hit

  • :request_cache (Boolean)

    Specify if request cache should be used for this request or not, defaults to index level setting

  • :batched_reduce_size (Number)

    The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large.

  • :max_concurrent_shard_requests (Number)

    The number of concurrent shard requests per node this search executes concurrently. 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

  • :pre_filter_shard_size (Number)

    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.

  • :rest_total_hits_as_int (Boolean)

    Indicates whether hits.total should be rendered as an integer or an object in the rest search response

  • :min_compatible_shard_node (String)

    The minimum compatible version that all shards involved in search should have for this request to be successful

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The search definition using the Query DSL



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/opensearch/api/actions/search.rb', line 85

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

  arguments = arguments.clone

  _index = arguments.delete(:index)

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

  path = if _index
           "#{Utils.__listify(_index)}/_search"
         else
           "_search"
         end
  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 = {}) ⇒ Object

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :index (List)

    A comma-separated list of index names to search; use ‘_all` or empty string to perform the operation on all indices

  • :preference (String)

    Specify the node or shard the operation should be performed on (default: random)

  • :routing (String)

    Specific routing value

  • :local (Boolean)

    Return local information, do not retrieve the state from cluster_manager node (default: false)

  • :ignore_unavailable (Boolean)

    Whether specified concrete indices should be ignored when unavailable (missing or closed)

  • :allow_no_indices (Boolean)

    Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes ‘_all` string or when no indices have been specified)

  • :expand_wildcards (String)

    Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)

  • :headers (Hash)

    Custom HTTP headers



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/opensearch/api/actions/search_shards.rb', line 42

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

  arguments = arguments.clone

  _index = arguments.delete(:index)

  method = OpenSearch::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 = {}) ⇒ Object

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

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :index (List)

    A comma-separated list of index names to search; use ‘_all` or empty string to perform the operation on all indices

  • :ignore_unavailable (Boolean)

    Whether specified concrete indices should be ignored when unavailable (missing or closed)

  • :ignore_throttled (Boolean)

    Whether specified concrete, expanded or aliased indices should be ignored when throttled

  • :allow_no_indices (Boolean)

    Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes ‘_all` string or when no indices have been specified)

  • :expand_wildcards (String)

    Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)

  • :preference (String)

    Specify the node or shard the operation should be performed on (default: random)

  • :routing (List)

    A comma-separated list of specific routing values

  • :scroll (Time)

    Specify how long a consistent view of the index should be maintained for scrolled search

  • :search_type (String)

    Search operation type (options: query_then_fetch, dfs_query_then_fetch)

  • :explain (Boolean)

    Specify whether to return detailed information about score computation as part of a hit

  • :profile (Boolean)

    Specify whether to profile the query execution

  • :typed_keys (Boolean)

    Specify whether aggregation and suggester names should be prefixed by their respective types in the response

  • :rest_total_hits_as_int (Boolean)

    Indicates whether hits.total should be rendered as an integer or an object in the rest search response

  • :ccs_minimize_roundtrips (Boolean)

    Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The search definition template and its params (Required)

Raises:

  • (ArgumentError)


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/opensearch/api/actions/search_template.rb', line 55

def search_template(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

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

  arguments = arguments.clone

  _index = arguments.delete(:index)

  method = OpenSearch::API::HTTP_POST
  path   = if _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 = {}) ⇒ Object

Deprecated: Use the plural version, #termvectors



86
87
88
# File 'lib/opensearch/api/actions/termvectors.rb', line 86

def termvector(arguments = {})
  termvectors(arguments.merge endpoint: '_termvector')
end

#termvectors(arguments = {}) ⇒ Object

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

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :index (String)

    The index in which the document resides. (Required)

  • :id (String)

    The id of the document, when not specified a doc param should be supplied.

  • :term_statistics (Boolean)

    Specifies if total term frequency and document frequency should be returned.

  • :field_statistics (Boolean)

    Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned.

  • :fields (List)

    A comma-separated list of fields to return.

  • :offsets (Boolean)

    Specifies if term offsets should be returned.

  • :positions (Boolean)

    Specifies if term positions should be returned.

  • :payloads (Boolean)

    Specifies if term payloads should be returned.

  • :preference (String)

    Specify the node or shard the operation should be performed on (default: random).

  • :routing (String)

    Specific routing value.

  • :realtime (Boolean)

    Specifies if request is real-time as opposed to near-real-time (default: true).

  • :version (Number)

    Explicit version number for concurrency control

  • :version_type (String)

    Specific version type (options: internal, external, external_gte, force)

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    Define parameters and or supply a document to get termvectors for. See documentation.

Raises:

  • (ArgumentError)


54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/opensearch/api/actions/termvectors.rb', line 54

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)

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

  endpoint = arguments.delete(:endpoint) || '_termvectors'
  path = if _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 = {}) ⇒ Object

Updates a document with a script or partial document.

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    Document ID

  • :index (String)

    The name of the index

  • :wait_for_active_shards (String)

    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)

  • :_source (List)

    True or false to return the _source field or not, or a list of fields to return

  • :_source_excludes (List)

    A list of fields to exclude from the returned _source field

  • :_source_includes (List)

    A list of fields to extract and return from the _source field

  • :lang (String)

    The script language (default: painless)

  • :refresh (String)

    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)

  • :retry_on_conflict (Number)

    Specify how many times should the operation be retried when a conflict occurs (default: 0)

  • :routing (String)

    Specific routing value

  • :timeout (Time)

    Explicit operation timeout

  • :if_seq_no (Number)

    only perform the update operation if the last operation that has changed the document has the specified sequence number

  • :if_primary_term (Number)

    only perform the update operation if the last operation that has changed the document has the specified primary term

  • :require_alias (Boolean)

    When true, requires destination is an alias. Default is false

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The request definition requires either ‘script` or partial `doc` (Required)

Raises:

  • (ArgumentError)


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/opensearch/api/actions/update.rb', line 55

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)

  method = OpenSearch::API::HTTP_POST
  path   = "#{Utils.__listify(_index)}/_update/#{Utils.__listify(_id)}"
  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 = {}) ⇒ Object

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

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :index (List)

    A comma-separated list of index names to search; use ‘_all` or empty string to perform the operation on all indices (Required)

  • :analyzer (String)

    The analyzer to use for the query string

  • :analyze_wildcard (Boolean)

    Specify whether wildcard and prefix queries should be analyzed (default: false)

  • :default_operator (String)

    The default operator for query string query (AND or OR) (options: AND, OR)

  • :df (String)

    The field to use as default where no field prefix is given in the query string

  • :from (Number)

    Starting offset (default: 0)

  • :ignore_unavailable (Boolean)

    Whether specified concrete indices should be ignored when unavailable (missing or closed)

  • :allow_no_indices (Boolean)

    Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes ‘_all` string or when no indices have been specified)

  • :conflicts (String)

    What to do when the update by query hits version conflicts? (options: abort, proceed)

  • :expand_wildcards (String)

    Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)

  • :lenient (Boolean)

    Specify whether format-based query failures (such as providing text to a numeric field) should be ignored

  • :pipeline (String)

    Ingest pipeline to set on index requests made by this action. (default: none)

  • :preference (String)

    Specify the node or shard the operation should be performed on (default: random)

  • :q (String)

    Query in the Lucene query string syntax

  • :routing (List)

    A comma-separated list of specific routing values

  • :scroll (Time)

    Specify how long a consistent view of the index should be maintained for scrolled search

  • :search_type (String)

    Search operation type (options: query_then_fetch, dfs_query_then_fetch)

  • :search_timeout (Time)

    Explicit timeout for each search request. Defaults to no timeout.

  • :size (Number)

    Deprecated, please use ‘max_docs` instead

  • :max_docs (Number)

    Maximum number of documents to process (default: all documents)

  • :sort (List)

    A comma-separated list of <field>:<direction> pairs

  • :_source (List)

    True or false to return the _source field or not, or a list of fields to return

  • :_source_excludes (List)

    A list of fields to exclude from the returned _source field

  • :_source_includes (List)

    A list of fields to extract and return from the _source field

  • :terminate_after (Number)

    The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.

  • :stats (List)

    Specific ‘tag’ of the request for logging and statistical purposes

  • :version (Boolean)

    Specify whether to return document version as part of a hit

  • :version_type (Boolean)

    Should the document increment the version number (internal) on hit or not (reindex)

  • :request_cache (Boolean)

    Specify if request cache should be used for this request or not, defaults to index level setting

  • :refresh (Boolean)

    Should the affected indexes be refreshed?

  • :timeout (Time)

    Time each individual bulk request should wait for shards that are unavailable.

  • :wait_for_active_shards (String)

    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)

  • :scroll_size (Number)

    Size on the scroll request powering the update by query

  • :wait_for_completion (Boolean)

    Should the request should block until the update by query operation is complete.

  • :requests_per_second (Number)

    The throttle to set on this request in sub-requests per second. -1 means no throttle.

  • :slices (Number|string)

    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`.

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The search definition using the Query DSL

Raises:

  • (ArgumentError)


78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/opensearch/api/actions/update_by_query.rb', line 78

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)

  method = OpenSearch::API::HTTP_POST
  path   = "#{Utils.__listify(_index)}/_update_by_query"
  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 = {}) ⇒ Object

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :task_id (String)

    The task id to rethrottle

  • :requests_per_second (Number)

    The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. (Required)

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/opensearch/api/actions/update_by_query_rethrottle.rb', line 37

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 = OpenSearch::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