module Elasticsearch::API::Actions
Public Instance Methods
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] :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 [String] :type Default document type for items which don’t provide one @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 [Boolean] :require_data_stream When true, requires the destination to be a data stream (existing or to-be-created). Default is false @option arguments [Boolean] :list_executed_pipelines Sets list_executed_pipelines 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/8.16/docs-bulk.html
# File lib/elasticsearch/api/actions/bulk.rb, line 45 def bulk(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'bulk' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index "#{Utils.__listify(_index)}/_bulk" else '_bulk' end params = Utils.process_params(arguments) payload = if body.is_a? Array Elasticsearch::API::Utils.__bulkify(body) else body end headers.merge!('Content-Type' => 'application/x-ndjson') Elasticsearch::API::Response.new( perform_request(method, path, params, payload, headers, request_opts) ) end
Checks if the specified combination of method, API
, parameters, and arbitrary capabilities are supported 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 [String] :method REST method to check (options: GET, HEAD, POST, PUT, DELETE) @option arguments [String] :path API
path to check @option arguments [String] :parameters Comma-separated list of API
parameters to check @option arguments [String] :capabilities Comma-separated list of arbitrary API
capabilities to check @option arguments [Boolean] :local_only True if only the node being called should be considered @option arguments [Hash] :headers Custom HTTP headers
# File lib/elasticsearch/api/actions/capabilities.rb, line 39 def capabilities(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'capabilities' } arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil method = Elasticsearch::API::HTTP_GET path = '_capabilities' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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/8.16/clear-scroll-api.html
# File lib/elasticsearch/api/actions/clear_scroll.rb, line 37 def clear_scroll(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'clear_scroll' } defined_params = [:scroll_id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _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 = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) Utils.__rescue_from_not_found do Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end else Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end end
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/8.16/point-in-time-api.html
# File lib/elasticsearch/api/actions/close_point_in_time.rb, line 31 def close_point_in_time(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'close_point_in_time' } arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) method = Elasticsearch::API::HTTP_DELETE path = '_pit' params = {} Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
Returns number of documents matching a query.
@option arguments [List] :index A comma-separated list of indices 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)
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/search-count.html
# File lib/elasticsearch/api/actions/count.rb, line 46 def count(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'count' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = if body Elasticsearch::API::HTTP_POST else Elasticsearch::API::HTTP_GET end path = if _index "#{Utils.__listify(_index)}/_count" else '_count' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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] :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)
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/docs-index_.html
# File lib/elasticsearch/api/actions/create.rb, line 42 def create(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'create' } defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? if arguments[:id] index arguments.update op_type: 'create' else index arguments end end
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] :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) @option arguments [Hash] :headers Custom HTTP headers
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/docs-delete.html
# File lib/elasticsearch/api/actions/delete.rb, line 40 def delete(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'delete' } defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _id = arguments.delete(:id) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_DELETE path = "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}" params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) Utils.__rescue_from_not_found do Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end else Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end end
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 @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] :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 [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 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 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)
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/docs-delete-by-query.html
# File lib/elasticsearch/api/actions/delete_by_query.rb, line 61 def delete_by_query(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'delete_by_query' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = "#{Utils.__listify(_index)}/_delete_by_query" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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/8.16/docs-delete-by-query.html
# File lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb, line 32 def delete_by_query_rethrottle(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'delete_by_query_rethrottle' } defined_params = [:task_id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _task_id = arguments.delete(:task_id) method = Elasticsearch::API::HTTP_POST path = "_delete_by_query/#{Utils.__listify(_task_id)}/_rethrottle" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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/8.16/modules-scripting.html
# File lib/elasticsearch/api/actions/delete_script.rb, line 33 def delete_script(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'delete_script' } defined_params = [:id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_DELETE path = "_scripts/#{Utils.__listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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 [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) @option arguments [Hash] :headers Custom HTTP headers
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/docs-get.html
# File lib/elasticsearch/api/actions/exists.rb, line 42 def exists(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'exists' } defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _id = arguments.delete(:id) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_HEAD path = "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}" params = Utils.process_params(arguments) Utils.__rescue_from_not_found do perform_request(method, path, params, body, headers, request_opts).status == 200 end end
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] :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) @option arguments [Hash] :headers Custom HTTP headers
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/docs-get.html
# File lib/elasticsearch/api/actions/exists_source.rb, line 41 def exists_source(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'exists_source' } defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _id = arguments.delete(:id) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_HEAD path = "#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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 [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
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/search-explain.html
# File lib/elasticsearch/api/actions/explain.rb, line 45 def explain(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'explain' } defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _id = arguments.delete(:id) _index = arguments.delete(:index) method = if body Elasticsearch::API::HTTP_POST else Elasticsearch::API::HTTP_GET end path = "#{Utils.__listify(_index)}/_explain/#{Utils.__listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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 [List] :filters An optional set of filters: can include +metadata,-metadata,-nested,-multifield,-parent @option arguments [List] :types Only return results for fields that have one of the types in the list @option arguments [Boolean] :include_empty_fields Include empty fields in result @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/8.16/search-field-caps.html
# File lib/elasticsearch/api/actions/field_caps.rb, line 40 def field_caps(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'field_caps' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = if 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.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
Returns a document.
@option arguments [String] :id The document ID @option arguments [String] :index The name of the index @option arguments [Boolean] :force_synthetic_source Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index. @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) @option arguments [Hash] :headers Custom HTTP headers
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/docs-get.html
# File lib/elasticsearch/api/actions/get.rb, line 43 def get(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'get' } defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _id = arguments.delete(:id) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}" params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) Utils.__rescue_from_not_found do Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end else Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end end
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/8.16/modules-scripting.html
# File lib/elasticsearch/api/actions/get_script.rb, line 32 def get_script(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'get_script' } defined_params = [:id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_GET path = "_scripts/#{Utils.__listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
Returns all script contexts.
@option arguments [Hash] :headers Custom HTTP headers
@see www.elastic.co/guide/en/elasticsearch/painless/8.16/painless-contexts.html
# File lib/elasticsearch/api/actions/get_script_context.rb, line 30 def get_script_context(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'get_script_context' } arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil method = Elasticsearch::API::HTTP_GET path = '_script_context' params = {} Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
Returns available script types, languages and contexts
@option arguments [Hash] :headers Custom HTTP headers
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/modules-scripting.html
# File lib/elasticsearch/api/actions/get_script_languages.rb, line 30 def get_script_languages(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'get_script_languages' } arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil method = Elasticsearch::API::HTTP_GET path = '_script_language' params = {} Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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] :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) @option arguments [Hash] :headers Custom HTTP headers
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/docs-get.html
# File lib/elasticsearch/api/actions/get_source.rb, line 41 def get_source(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'get_source' } defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _id = arguments.delete(:id) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = "#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
Returns the health of the cluster.
@option arguments [String] :feature A feature of the cluster, as returned by the top-level health API
@option arguments [Time] :timeout Explicit operation timeout @option arguments [Boolean] :verbose Opt in for more information about the health of the system @option arguments [Integer] :size Limit the number of affected resources the health API
returns @option arguments [Hash] :headers Custom HTTP headers
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/health-api.html
# File lib/elasticsearch/api/actions/health_report.rb, line 34 def health_report(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'health_report' } defined_params = [:feature].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _feature = arguments.delete(:feature) method = Elasticsearch::API::HTTP_GET path = if _feature "_health_report/#{Utils.__listify(_feature)}" else '_health_report' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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] :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 [Boolean] :require_data_stream When true, requires the destination to be a data stream (existing or to-be-created). Default is false @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The document (Required)
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/docs-index_.html
# File lib/elasticsearch/api/actions/index.rb, line 45 def index(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'index' } defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _id = arguments.delete(:id) _index = arguments.delete(:index) method = _id ? Elasticsearch::API::HTTP_PUT : Elasticsearch::API::HTTP_POST path = if _index && _id "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}" else "#{Utils.__listify(_index)}/_doc" end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
Returns basic information about the cluster.
@option arguments [Hash] :headers Custom HTTP headers
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/index.html
# File lib/elasticsearch/api/actions/info.rb, line 30 def info(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'info' } arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil method = Elasticsearch::API::HTTP_GET path = '' params = {} Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
Performs a kNN search. 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` to perform the operation on all indices @option arguments [List] :routing A comma-separated list of specific routing values @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The search definition
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/search-search.html
# File lib/elasticsearch/api/actions/knn_search.rb, line 37 def knn_search(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'knn_search' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = if body Elasticsearch::API::HTTP_POST else Elasticsearch::API::HTTP_GET end path = "#{Utils.__listify(_index)}/_knn_search" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
Allows to get multiple documents in one request.
@option arguments [String] :index The name of the index @option arguments [Boolean] :force_synthetic_source Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index. @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 is provided in the URL. (Required)
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/docs-multi-get.html
# File lib/elasticsearch/api/actions/mget.rb, line 41 def mget(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'mget' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index "#{Utils.__listify(_index)}/_mget" else '_mget' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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 [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)
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/search-multi-search.html
# File lib/elasticsearch/api/actions/msearch.rb, line 39 def msearch(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'msearch' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index "#{Utils.__listify(_index)}/_msearch" else '_msearch' end params = Utils.process_params(arguments) if body.is_a?(Array) && body.any? { |d| d.has_key? :search } payload = body.each_with_object([]) do |item, sum| meta = item data = meta.delete(:search) sum << meta sum << data end.map { |item| Elasticsearch::API.serializer.dump(item) } payload << '' unless payload.empty? payload = payload.join("\n") elsif 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') Elasticsearch::API::Response.new( perform_request(method, path, params, payload, headers, request_opts) ) end
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 [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)
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/search-multi-search.html
# File lib/elasticsearch/api/actions/msearch_template.rb, line 37 def msearch_template(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'msearch_template' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index "#{Utils.__listify(_index)}/_msearch/template" else '_msearch/template' end params = Utils.process_params(arguments) if 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') Elasticsearch::API::Response.new( perform_request(method, path, params, payload, headers, request_opts) ) end
Returns multiple termvectors in one request.
@option arguments [String] :index The index in which the document resides. @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) @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.
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/docs-multi-termvectors.html
# File lib/elasticsearch/api/actions/mtermvectors.rb, line 44 def mtermvectors(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'mtermvectors' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? arguments = arguments.clone headers = arguments.delete(:headers) || {} body = if (ids = arguments.delete(:ids)) { ids: ids } else arguments.delete(:body) end _index = arguments.delete(:index) method = if body Elasticsearch::API::HTTP_POST else Elasticsearch::API::HTTP_GET end path = if _index "#{Utils.__listify(_index)}/_mtermvectors" else '_mtermvectors' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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 (Required) @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/8.16/point-in-time-api.html
# File lib/elasticsearch/api/actions/open_point_in_time.rb, line 37 def open_point_in_time(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'open_point_in_time' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = "#{Utils.__listify(_index)}/_pit" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
Returns whether the cluster is running.
@option arguments [Hash] :headers Custom HTTP headers
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/index.html
# File lib/elasticsearch/api/actions/ping.rb, line 30 def ping(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'ping' } arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil method = Elasticsearch::API::HTTP_HEAD path = '' params = {} begin perform_request(method, path, params, body, headers, request_opts).status == 200 rescue Exception => e raise e unless e.class.to_s =~ /NotFound|ConnectionFailed/ || e.message =~ /Not *Found|404|ConnectionFailed/i false end end
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/8.16/modules-scripting.html
# File lib/elasticsearch/api/actions/put_script.rb, line 35 def put_script(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'put_script' } defined_params = %i[id context].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _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.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
Allows to evaluate the quality of ranked search results over a set of typical search queries
@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/8.16/search-rank-eval.html
# File lib/elasticsearch/api/actions/rank_eval.rb, line 36 def rank_eval(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'rank_eval' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index "#{Utils.__listify(_index)}/_rank_eval" else '_rank_eval' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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/8.16/docs-reindex.html
# File lib/elasticsearch/api/actions/reindex.rb, line 41 def reindex(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'reindex' } raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST path = '_reindex' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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/8.16/docs-reindex.html
# File lib/elasticsearch/api/actions/reindex_rethrottle.rb, line 32 def reindex_rethrottle(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'reindex_rethrottle' } defined_params = [:task_id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _task_id = arguments.delete(:task_id) method = Elasticsearch::API::HTTP_POST path = "_reindex/#{Utils.__listify(_task_id)}/_rethrottle" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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/8.16/render-search-template-api.html
# File lib/elasticsearch/api/actions/render_search_template.rb, line 32 def render_search_template(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'render_search_template' } defined_params = [:id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _id = arguments.delete(:id) method = if body Elasticsearch::API::HTTP_POST else Elasticsearch::API::HTTP_GET end path = if _id "_render/template/#{Utils.__listify(_id)}" else '_render/template' end params = {} Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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/8.16/painless-execute-api.html
# File lib/elasticsearch/api/actions/scripts_painless_execute.rb, line 35 def scripts_painless_execute(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'scripts_painless_execute' } arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) method = if body Elasticsearch::API::HTTP_POST else Elasticsearch::API::HTTP_GET end path = '_scripts/painless/_execute' params = {} Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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
# File lib/elasticsearch/api/actions/scroll.rb, line 39 def scroll(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'scroll' } defined_params = [:scroll_id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _scroll_id = arguments.delete(:scroll_id) method = if 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.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
Returns results matching a 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 @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 [Boolean] :ccs_minimize_roundtrips Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution @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] :explain Specify whether to return detailed information about score computation as part of a hit @option arguments [List] :stored_fields A comma-separated list of stored fields to return as part of a hit @option arguments [List] :docvalue_fields A comma-separated list of fields to return as the docvalue representation of a field for each hit @option arguments [Number] :from Starting offset (default: 0) @option arguments [Boolean] :force_synthetic_source Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index. @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 [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 [Number] :size Number of hits to return (default: 10) @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 [String] :suggest_field Specify which field to use for suggestions @option arguments [String] :suggest_mode Specify suggest mode (options: missing, popular, always) @option arguments [Number] :suggest_size How many suggestions to return in response @option arguments [String] :suggest_text The source text for which the suggestions should be returned @option arguments [Time] :timeout Explicit operation timeout @option arguments [Boolean] :track_scores Whether to calculate and return scores even if they are not used for sorting @option arguments [Boolean|long] :track_total_hits Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number. @option arguments [Boolean] :allow_partial_search_results Indicate if an error should be returned if there is a partial search failure or timeout @option arguments [Boolean] :typed_keys Specify whether aggregation and suggester names should be prefixed by their respective types in the response @option arguments [Boolean] :version Specify whether to return document version as part of a hit @option arguments [Boolean] :seq_no_primary_term Specify whether to return sequence number and primary term of the last modification of each 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 [Number] :batched_reduce_size 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. @option arguments [Number] :max_concurrent_shard_requests 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 @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 [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 [String] :min_compatible_shard_node The minimum compatible version that all shards involved in search should have for this request to be successful @option arguments [Boolean] :include_named_queries_score Indicates whether hit.matched_queries should be rendered as a map that includes the name of the matched query associated with its score (true) or as an array containing the name of the matched queries (false) @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The search definition using the Query DSL
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/search-search.html
# File lib/elasticsearch/api/actions/search.rb, line 77 def search(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'search' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = if body Elasticsearch::API::HTTP_POST else Elasticsearch::API::HTTP_GET end path = if _index "#{Utils.__listify(_index)}/_search" else '_search' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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, centroid) @option arguments [Integer] :size Maximum number of features to return in the hits layer. Accepts 0-10000. @option arguments [Boolean|long] :track_total_hits Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number. @option arguments [Boolean] :with_labels If true, the hits and aggs layers will contain additional point features with suggested label positions for the original features. @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body Search request body.
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/search-vector-tile-api.html
# File lib/elasticsearch/api/actions/search_mvt.rb, line 47 def search_mvt(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'search_mvt' } defined_params = %i[index field zoom x y].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? 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] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _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.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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 [Time] :master_timeout Explicit operation timeout for connection to master node @option arguments [Hash] :headers Custom HTTP headers
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/search-shards.html
# File lib/elasticsearch/api/actions/search_shards.rb, line 38 def search_shards(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'search_shards' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = if _index "#{Utils.__listify(_index)}/_search_shards" else '_search_shards' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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 [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)
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/search-template.html
# File lib/elasticsearch/api/actions/search_template.rb, line 45 def search_template(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'search_template' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index "#{Utils.__listify(_index)}/_search/template" else '_search/template' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
The terms enum API
can be used to discover terms in the index that begin with the provided string. It is designed for low-latency look-ups used in auto-complete scenarios.
@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 [Hash] :headers Custom HTTP headers @option arguments [Hash] :body field name, string which is the prefix expected in matching terms, timeout and size for max number of results
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/search-terms-enum.html
# File lib/elasticsearch/api/actions/terms_enum.rb, line 32 def terms_enum(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'terms_enum' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = if body Elasticsearch::API::HTTP_POST else Elasticsearch::API::HTTP_GET end path = "#{Utils.__listify(_index)}/_terms_enum" params = {} Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
Deprecated: Use the plural version, {#termvectors}
# File lib/elasticsearch/api/actions/termvectors.rb, line 84 def termvector(arguments = {}) warn '[DEPRECATION] `termvector` is deprecated. Please use the plural version, `termvectors` instead.' termvectors(arguments.merge(endpoint: '_termvector')) end
Returns information and statistics about terms in the fields of a particular document.
@option arguments [String] :index The index in which the document resides. @option arguments [String] :id The id of the document, when not specified a doc param should be supplied. @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) @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body Define parameters and or supply a document to get termvectors for. See documentation.
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/docs-termvectors.html
# File lib/elasticsearch/api/actions/termvectors.rb, line 44 def termvectors(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'termvectors' } defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) _id = arguments.delete(:id) method = if body Elasticsearch::API::HTTP_POST else Elasticsearch::API::HTTP_GET end arguments.delete(:endpoint) path = if _index && _id "#{Utils.__listify(_index)}/_termvectors/#{Utils.__listify(_id)}" else "#{Utils.__listify(_index)}/_termvectors" end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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] :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)
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/docs-update.html
# File lib/elasticsearch/api/actions/update.rb, line 45 def update(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'update' } defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? 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] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _id = arguments.delete(:id) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = "#{Utils.__listify(_index)}/_update/#{Utils.__listify(_id)}" params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) Utils.__rescue_from_not_found do Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end else Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end end
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 @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] :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 [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
@see www.elastic.co/guide/en/elasticsearch/reference/8.16/docs-update-by-query.html
# File lib/elasticsearch/api/actions/update_by_query.rb, line 64 def update_by_query(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'update_by_query' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = "#{Utils.__listify(_index)}/_update_by_query" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
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/8.16/docs-update-by-query.html
# File lib/elasticsearch/api/actions/update_by_query_rethrottle.rb, line 32 def update_by_query_rethrottle(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'update_by_query_rethrottle' } defined_params = [:task_id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _task_id = arguments.delete(:task_id) method = Elasticsearch::API::HTTP_POST path = "_update_by_query/#{Utils.__listify(_task_id)}/_rethrottle" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end