Module: ElasticsearchServerless::API::Indices::Actions
- Defined in:
- lib/elasticsearch-serverless/api/indices/get.rb,
lib/elasticsearch-serverless/api/indices/create.rb,
lib/elasticsearch-serverless/api/indices/delete.rb,
lib/elasticsearch-serverless/api/indices/exists.rb,
lib/elasticsearch-serverless/api/indices/analyze.rb,
lib/elasticsearch-serverless/api/indices/refresh.rb,
lib/elasticsearch-serverless/api/indices/rollover.rb,
lib/elasticsearch-serverless/api/indices/add_block.rb,
lib/elasticsearch-serverless/api/indices/get_alias.rb,
lib/elasticsearch-serverless/api/indices/put_alias.rb,
lib/elasticsearch-serverless/api/indices/get_mapping.rb,
lib/elasticsearch-serverless/api/indices/put_mapping.rb,
lib/elasticsearch-serverless/api/indices/delete_alias.rb,
lib/elasticsearch-serverless/api/indices/exists_alias.rb,
lib/elasticsearch-serverless/api/indices/get_settings.rb,
lib/elasticsearch-serverless/api/indices/put_settings.rb,
lib/elasticsearch-serverless/api/indices/resolve_index.rb,
lib/elasticsearch-serverless/api/indices/update_aliases.rb,
lib/elasticsearch-serverless/api/indices/validate_query.rb,
lib/elasticsearch-serverless/api/indices/get_data_stream.rb,
lib/elasticsearch-serverless/api/indices/simulate_template.rb,
lib/elasticsearch-serverless/api/indices/create_data_stream.rb,
lib/elasticsearch-serverless/api/indices/delete_data_stream.rb,
lib/elasticsearch-serverless/api/indices/get_data_lifecycle.rb,
lib/elasticsearch-serverless/api/indices/get_index_template.rb,
lib/elasticsearch-serverless/api/indices/modify_data_stream.rb,
lib/elasticsearch-serverless/api/indices/put_data_lifecycle.rb,
lib/elasticsearch-serverless/api/indices/put_index_template.rb,
lib/elasticsearch-serverless/api/indices/delete_index_template.rb,
lib/elasticsearch-serverless/api/indices/exists_index_template.rb,
lib/elasticsearch-serverless/api/indices/explain_data_lifecycle.rb,
lib/elasticsearch-serverless/api/indices/migrate_to_data_stream.rb,
lib/elasticsearch-serverless/api/indices/simulate_index_template.rb
Instance Method Summary collapse
-
#add_block(arguments = {}) ⇒ Object
Add an index block.
-
#analyze(arguments = {}) ⇒ Object
Get tokens from text analysis.
-
#create(arguments = {}) ⇒ Object
Create an index.
-
#create_data_stream(arguments = {}) ⇒ Object
Create a data stream.
-
#delete(arguments = {}) ⇒ Object
Delete indices.
-
#delete_alias(arguments = {}) ⇒ Object
Delete an alias.
-
#delete_data_stream(arguments = {}) ⇒ Object
Delete data streams.
-
#delete_index_template(arguments = {}) ⇒ Object
Delete an index template.
-
#exists(arguments = {}) ⇒ Object
(also: #exists?)
Check indices.
-
#exists_alias(arguments = {}) ⇒ Object
(also: #exists_alias?)
Check aliases.
-
#exists_index_template(arguments = {}) ⇒ Object
(also: #exists_index_template?)
Check index templates.
-
#explain_data_lifecycle(arguments = {}) ⇒ Object
Get the status for a data stream lifecycle.
-
#get(arguments = {}) ⇒ Object
Get index information.
-
#get_alias(arguments = {}) ⇒ Object
Get aliases.
-
#get_data_lifecycle(arguments = {}) ⇒ Object
Get data stream lifecycles.
-
#get_data_stream(arguments = {}) ⇒ Object
Get data streams.
-
#get_index_template(arguments = {}) ⇒ Object
Get index templates.
-
#get_mapping(arguments = {}) ⇒ Object
Get mapping definitions.
-
#get_settings(arguments = {}) ⇒ Object
Get index settings.
-
#migrate_to_data_stream(arguments = {}) ⇒ Object
Convert an index alias to a data stream.
-
#modify_data_stream(arguments = {}) ⇒ Object
Update data streams.
-
#put_alias(arguments = {}) ⇒ Object
Create or update an alias.
-
#put_data_lifecycle(arguments = {}) ⇒ Object
Update data stream lifecycles.
-
#put_index_template(arguments = {}) ⇒ Object
Create or update an index template.
-
#put_mapping(arguments = {}) ⇒ Object
Update field mappings.
-
#put_settings(arguments = {}) ⇒ Object
Update index settings.
-
#refresh(arguments = {}) ⇒ Object
Refresh an index.
-
#resolve_index(arguments = {}) ⇒ Object
Resolve indices.
-
#rollover(arguments = {}) ⇒ Object
Roll over to a new index.
-
#simulate_index_template(arguments = {}) ⇒ Object
Simulate an index.
-
#simulate_template(arguments = {}) ⇒ Object
Simulate an index template.
-
#update_aliases(arguments = {}) ⇒ Object
Create or update an alias.
-
#validate_query(arguments = {}) ⇒ Object
Validate a query.
Instance Method Details
#add_block(arguments = {}) ⇒ Object
Add an index block. Add an index block to an index. Index blocks limit the operations allowed on an index by blocking specific operation types.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/elasticsearch-serverless/api/indices/add_block.rb', line 51 def add_block(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.add_block' } defined_params = [:index, :block].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 'block' missing" unless arguments[:block] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _index = arguments.delete(:index) _block = arguments.delete(:block) method = ElasticsearchServerless::API::HTTP_PUT path = "#{Utils.listify(_index)}/_block/#{Utils.listify(_block)}" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#analyze(arguments = {}) ⇒ Object
Get tokens from text analysis. The analyze API performs analysis on a text string and returns the resulting tokens. Generating excessive amount of tokens may cause a node to run out of memory. The index.analyze.max_token_count setting enables you to limit the number of tokens that can be produced. If more than this limit of tokens gets generated, an error occurs. The _analyze endpoint without a specified index will always use 10000 as its limit.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/elasticsearch-serverless/api/indices/analyze.rb', line 40 def analyze(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.analyze' } 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 ElasticsearchServerless::API::HTTP_POST else ElasticsearchServerless::API::HTTP_GET end path = if _index "#{Utils.listify(_index)}/_analyze" else '_analyze' end params = {} ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#create(arguments = {}) ⇒ Object
Create an index. You can use the create index API to add a new index to an Elasticsearch cluster. When creating an index, you can specify the following:
-
Settings for the index.
-
Mappings for fields in the index.
-
Index aliases
**Wait for active shards** By default, index creation will only return a response to the client when the primary copies of each shard have been started, or the request times out. The index creation response will indicate what happened. For example, acknowledged indicates whether the index was successfully created in the cluster, while shards_acknowledged indicates whether the requisite number of shard copies were started for each shard in the index before timing out. Note that it is still possible for either acknowledged or shards_acknowledged to be false, but for the index creation to be successful. These values simply indicate whether the operation completed before the timeout. If acknowledged is false, the request timed out before the cluster state was updated with the newly created index, but it probably will be created sometime soon. If shards_acknowledged is false, then the request timed out before the requisite number of shards were started (by default just the primaries), even if the cluster state was successfully updated to reflect the newly created index (that is to say, acknowledged is true). You can change the default of only waiting for the primary shards to start through the index setting index.write.wait_for_active_shards. Note that changing this setting will also affect the wait_for_active_shards value on all subsequent write operations.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/elasticsearch-serverless/api/indices/create.rb', line 54 def create(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.create' } 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 = ElasticsearchServerless::API::HTTP_PUT path = Utils.listify(_index).to_s params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#create_data_stream(arguments = {}) ⇒ Object
Create a data stream. You must have a matching index template with data stream enabled.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/elasticsearch-serverless/api/indices/create_data_stream.rb', line 40 def create_data_stream(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.create_data_stream' } defined_params = [:name].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 'name' missing" unless arguments[:name] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _name = arguments.delete(:name) method = ElasticsearchServerless::API::HTTP_PUT path = "_data_stream/#{Utils.listify(_name)}" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#delete(arguments = {}) ⇒ Object
Delete indices. Deleting an index deletes its documents, shards, and metadata. It does not delete related Kibana components, such as data views, visualizations, or dashboards. You cannot delete the current write index of a data stream. To delete the index, you must roll over the data stream so a new write index is created. You can then use the delete index API to delete the previous write index.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/elasticsearch-serverless/api/indices/delete.rb', line 51 def delete(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.delete' } 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 = nil _index = arguments.delete(:index) method = ElasticsearchServerless::API::HTTP_DELETE path = Utils.listify(_index).to_s params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) Utils.rescue_from_not_found do ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end else ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end end |
#delete_alias(arguments = {}) ⇒ Object
Delete an alias. Removes a data stream or index from an alias.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/elasticsearch-serverless/api/indices/delete_alias.rb', line 40 def delete_alias(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.delete_alias' } defined_params = [:index, :name].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 'name' missing" unless arguments[:name] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _index = arguments.delete(:index) _name = arguments.delete(:name) method = ElasticsearchServerless::API::HTTP_DELETE path = ("#{Utils.listify(_index)}/_aliases/#{Utils.listify(_name)}" if _index && _name) params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#delete_data_stream(arguments = {}) ⇒ Object
Delete data streams. Deletes one or more data streams and their backing indices.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/elasticsearch-serverless/api/indices/delete_data_stream.rb', line 35 def delete_data_stream(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.delete_data_stream' } defined_params = [:name].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 'name' missing" unless arguments[:name] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _name = arguments.delete(:name) method = ElasticsearchServerless::API::HTTP_DELETE path = "_data_stream/#{Utils.listify(_name)}" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#delete_index_template(arguments = {}) ⇒ Object
Delete an index template. The provided <index-template> may contain multiple template names separated by a comma. If multiple template names are specified then there is no wildcard support and the provided names should match completely with existing templates.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/elasticsearch-serverless/api/indices/delete_index_template.rb', line 37 def delete_index_template(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.delete_index_template' } defined_params = [:name].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 'name' missing" unless arguments[:name] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _name = arguments.delete(:name) method = ElasticsearchServerless::API::HTTP_DELETE path = "_index_template/#{Utils.listify(_name)}" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#exists(arguments = {}) ⇒ Object Also known as: exists?
Check indices. Check if one or more indices, index aliases, or data streams exist.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/elasticsearch-serverless/api/indices/exists.rb', line 43 def exists(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.exists' } 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 = nil _index = arguments.delete(:index) method = ElasticsearchServerless::API::HTTP_HEAD path = Utils.listify(_index).to_s params = Utils.process_params(arguments) Utils.rescue_from_not_found do perform_request(method, path, params, body, headers, request_opts).status == 200 end end |
#exists_alias(arguments = {}) ⇒ Object Also known as: exists_alias?
Check aliases. Check if one or more data stream or index aliases exist.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/elasticsearch-serverless/api/indices/exists_alias.rb', line 44 def exists_alias(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.exists_alias' } defined_params = [:name, :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 'name' missing" unless arguments[:name] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _name = arguments.delete(:name) _index = arguments.delete(:index) method = ElasticsearchServerless::API::HTTP_HEAD path = if _index && _name "#{Utils.listify(_index)}/_alias/#{Utils.listify(_name)}" else "_alias/#{Utils.listify(_name)}" end params = Utils.process_params(arguments) Utils.rescue_from_not_found do perform_request(method, path, params, body, headers, request_opts).status == 200 end end |
#exists_index_template(arguments = {}) ⇒ Object Also known as: exists_index_template?
Check index templates. Check whether index templates exist.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/elasticsearch-serverless/api/indices/exists_index_template.rb', line 34 def exists_index_template(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.exists_index_template' } defined_params = [:name].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 'name' missing" unless arguments[:name] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _name = arguments.delete(:name) method = ElasticsearchServerless::API::HTTP_HEAD path = "_index_template/#{Utils.listify(_name)}" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#explain_data_lifecycle(arguments = {}) ⇒ Object
Get the status for a data stream lifecycle. Get information about an index or data stream’s current data stream lifecycle status, such as time since index creation, time since rollover, the lifecycle configuration managing the index, or any errors encountered during lifecycle execution.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/elasticsearch-serverless/api/indices/explain_data_lifecycle.rb', line 35 def explain_data_lifecycle(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.explain_data_lifecycle' } 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 = nil _index = arguments.delete(:index) method = ElasticsearchServerless::API::HTTP_GET path = "#{Utils.listify(_index)}/_lifecycle/explain" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#get(arguments = {}) ⇒ Object
Get index information. Get information about one or more indices. For data streams, the API returns information about the stream’s backing indices.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/elasticsearch-serverless/api/indices/get.rb', line 47 def get(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.get' } 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 = nil _index = arguments.delete(:index) method = ElasticsearchServerless::API::HTTP_GET path = Utils.listify(_index).to_s params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#get_alias(arguments = {}) ⇒ Object
Get aliases. Retrieves information for one or more data stream or index aliases.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/elasticsearch-serverless/api/indices/get_alias.rb', line 47 def get_alias(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.get_alias' } defined_params = [:name, :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 _name = arguments.delete(:name) _index = arguments.delete(:index) method = ElasticsearchServerless::API::HTTP_GET path = if _index && _name "#{Utils.listify(_index)}/_alias/#{Utils.listify(_name)}" elsif _index "#{Utils.listify(_index)}/_alias" elsif _name "_alias/#{Utils.listify(_name)}" else '_alias' end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#get_data_lifecycle(arguments = {}) ⇒ Object
Get data stream lifecycles. Get the data stream lifecycle configuration of one or more data streams.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/elasticsearch-serverless/api/indices/get_data_lifecycle.rb', line 40 def get_data_lifecycle(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.get_data_lifecycle' } defined_params = [:name].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 'name' missing" unless arguments[:name] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _name = arguments.delete(:name) method = ElasticsearchServerless::API::HTTP_GET path = "_data_stream/#{Utils.listify(_name)}/_lifecycle" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#get_data_stream(arguments = {}) ⇒ Object
Get data streams. Get information about one or more data streams.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/elasticsearch-serverless/api/indices/get_data_stream.rb', line 39 def get_data_stream(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.get_data_stream' } defined_params = [:name].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 _name = arguments.delete(:name) method = ElasticsearchServerless::API::HTTP_GET path = if _name "_data_stream/#{Utils.listify(_name)}" else '_data_stream' end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#get_index_template(arguments = {}) ⇒ Object
Get index templates. Get information about one or more index templates.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/elasticsearch-serverless/api/indices/get_index_template.rb', line 37 def get_index_template(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.get_index_template' } defined_params = [:name].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 _name = arguments.delete(:name) method = ElasticsearchServerless::API::HTTP_GET path = if _name "_index_template/#{Utils.listify(_name)}" else '_index_template' end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#get_mapping(arguments = {}) ⇒ Object
Get mapping definitions. For data streams, the API retrieves mappings for the stream’s backing indices.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/elasticsearch-serverless/api/indices/get_mapping.rb', line 45 def get_mapping(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.get_mapping' } 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 = ElasticsearchServerless::API::HTTP_GET path = if _index "#{Utils.listify(_index)}/_mapping" else '_mapping' end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#get_settings(arguments = {}) ⇒ Object
Get index settings. Get setting information for one or more indices. For data streams, it returns setting information for the stream’s backing indices.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/elasticsearch-serverless/api/indices/get_settings.rb', line 53 def get_settings(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.get_settings' } defined_params = [:index, :name].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) _name = arguments.delete(:name) method = ElasticsearchServerless::API::HTTP_GET path = if _index && _name "#{Utils.listify(_index)}/_settings/#{Utils.listify(_name)}" elsif _index "#{Utils.listify(_index)}/_settings" elsif _name "_settings/#{Utils.listify(_name)}" else '_settings' end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#migrate_to_data_stream(arguments = {}) ⇒ Object
Convert an index alias to a data stream. Converts an index alias to a data stream. You must have a matching index template that is data stream enabled. The alias must meet the following criteria: The alias must have a write index; All indices for the alias must have a @timestamp field mapping of a date or date_nanos field type; The alias must not have any filters; The alias must not use custom routing. If successful, the request removes the alias and creates a data stream with the same name. The indices for the alias become hidden backing indices for the stream. The write index for the alias becomes the write index for the stream.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/elasticsearch-serverless/api/indices/migrate_to_data_stream.rb', line 44 def migrate_to_data_stream(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.migrate_to_data_stream' } defined_params = [:name].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 'name' missing" unless arguments[:name] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _name = arguments.delete(:name) method = ElasticsearchServerless::API::HTTP_POST path = "_data_stream/_migrate/#{Utils.listify(_name)}" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#modify_data_stream(arguments = {}) ⇒ Object
Update data streams. Performs one or more data stream modification actions in a single atomic operation.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/elasticsearch-serverless/api/indices/modify_data_stream.rb', line 33 def modify_data_stream(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.modify_data_stream' } raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) method = ElasticsearchServerless::API::HTTP_POST path = '_data_stream/_modify' params = {} ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#put_alias(arguments = {}) ⇒ Object
Create or update an alias. Adds a data stream or index to an alias.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/elasticsearch-serverless/api/indices/put_alias.rb', line 43 def put_alias(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.put_alias' } defined_params = [:index, :name].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 'name' missing" unless arguments[:name] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) _name = arguments.delete(:name) method = ElasticsearchServerless::API::HTTP_PUT path = ("#{Utils.listify(_index)}/_aliases/#{Utils.listify(_name)}" if _index && _name) params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#put_data_lifecycle(arguments = {}) ⇒ Object
Update data stream lifecycles. Update the data stream lifecycle of the specified data streams.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/elasticsearch-serverless/api/indices/put_data_lifecycle.rb', line 44 def put_data_lifecycle(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.put_data_lifecycle' } defined_params = [:name].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 'name' missing" unless arguments[:name] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _name = arguments.delete(:name) method = ElasticsearchServerless::API::HTTP_PUT path = "_data_stream/#{Utils.listify(_name)}/_lifecycle" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#put_index_template(arguments = {}) ⇒ Object
Create or update an index template. Index templates define settings, mappings, and aliases that can be applied automatically to new indices. Elasticsearch applies templates to new indices based on an wildcard pattern that matches the index name. Index templates are applied during data stream or index creation. For data streams, these settings and mappings are applied when the stream’s backing indices are created. Settings and mappings specified in a create index API request override any settings or mappings specified in an index template. Changes to index templates do not affect existing indices, including the existing backing indices of a data stream. You can use C-style /* */ block comments in index templates. You can include comments anywhere in the request body, except before the opening curly bracket. **Multiple matching templates** If multiple index templates match the name of a new index or data stream, the template with the highest priority is used. Multiple templates with overlapping index patterns at the same priority are not allowed and an error will be thrown when attempting to create a template matching an existing index template at identical priorities. **Composing aliases, mappings, and settings** When multiple component templates are specified in the composed_of field for an index template, they are merged in the order specified, meaning that later component templates override earlier component templates. Any mappings, settings, or aliases from the parent index template are merged in next. Finally, any configuration on the index request itself is merged. Mapping definitions are merged recursively, which means that later mapping components can introduce new field mappings and update the mapping configuration. If a field mapping is already contained in an earlier component, its definition will be completely overwritten by the later one. This recursive merging strategy applies not only to field mappings, but also root options like dynamic_templates and meta. If an earlier component contains a dynamic_templates block, then by default new dynamic_templates entries are appended onto the end. If an entry already exists with the same key, then it is overwritten by the new definition.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/elasticsearch-serverless/api/indices/put_index_template.rb', line 57 def put_index_template(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.put_index_template' } defined_params = [:name].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 'name' missing" unless arguments[:name] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _name = arguments.delete(:name) method = ElasticsearchServerless::API::HTTP_PUT path = "_index_template/#{Utils.listify(_name)}" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#put_mapping(arguments = {}) ⇒ Object
Update field mappings. Add new fields to an existing data stream or index. You can also use this API to change the search settings of existing fields and add new properties to existing object fields. For data streams, these changes are applied to all backing indices by default. **Add multi-fields to an existing field** Multi-fields let you index the same field in different ways. You can use this API to update the fields mapping parameter and enable multi-fields for an existing field. WARNING: If an index (or data stream) contains documents when you add a multi-field, those documents will not have values for the new multi-field. You can populate the new multi-field with the update by query API. **Change supported mapping parameters for an existing field** The documentation for each mapping parameter indicates whether you can update it for an existing field using this API. For example, you can use the update mapping API to update the ignore_above parameter. **Change the mapping of an existing field** Except for supported mapping parameters, you can’t change the mapping or field type of an existing field. Changing an existing field could invalidate data that’s already indexed. If you need to change the mapping of a field in a data stream’s backing indices, refer to documentation about modifying data streams. If you need to change the mapping of a field in other indices, create a new index with the correct mapping and reindex your data into that index. **Rename a field** Renaming a field would invalidate data already indexed under the old field name. Instead, add an alias field to create an alternate field name.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/elasticsearch-serverless/api/indices/put_mapping.rb', line 64 def put_mapping(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.put_mapping' } 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 = ElasticsearchServerless::API::HTTP_PUT path = "#{Utils.listify(_index)}/_mapping" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#put_settings(arguments = {}) ⇒ Object
Update index settings. Changes dynamic index settings in real time. For data streams, index setting changes are applied to all backing indices by default. To revert a setting to the default value, use a null value. The list of per-index settings that can be updated dynamically on live indices can be found in index module documentation. To preserve existing settings from being updated, set the preserve_existing parameter to true. NOTE: You can only define new analyzers on closed indices. To add an analyzer, you must close the index, define the analyzer, and reopen the index. You cannot close the write index of a data stream. To update the analyzer for a data stream’s write index and future backing indices, update the analyzer in the index template used by the stream. Then roll over the data stream to apply the new analyzer to the stream’s write index and future backing indices. This affects searches and any new data added to the stream after the rollover. However, it does not affect the data stream’s backing indices or their existing data. To change the analyzer for existing backing indices, you must create a new data stream and reindex your data into it.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/elasticsearch-serverless/api/indices/put_settings.rb', line 65 def put_settings(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.put_settings' } 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 = ElasticsearchServerless::API::HTTP_PUT path = if _index "#{Utils.listify(_index)}/_settings" else '_settings' end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#refresh(arguments = {}) ⇒ Object
Refresh an index. A refresh makes recent operations performed on one or more indices available for search. For data streams, the API runs the refresh operation on the stream’s backing indices. By default, Elasticsearch periodically refreshes indices every second, but only on indices that have received one search request or more in the last 30 seconds. You can change this default interval with the index.refresh_interval setting. Refresh requests are synchronous and do not return a response until the refresh operation completes. Refreshes are resource-intensive. To ensure good cluster performance, it’s recommended to wait for Elasticsearch’s periodic refresh rather than performing an explicit refresh when possible. If your application workflow indexes documents and then runs a search to retrieve the indexed document, it’s recommended to use the index API’s refresh=wait_for query parameter option. This option ensures the indexing operation waits for a periodic refresh before running the search.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/elasticsearch-serverless/api/indices/refresh.rb', line 50 def refresh(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.refresh' } 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 = ElasticsearchServerless::API::HTTP_POST path = if _index "#{Utils.listify(_index)}/_refresh" else '_refresh' end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#resolve_index(arguments = {}) ⇒ Object
Resolve indices. Resolve the names and/or index patterns for indices, aliases, and data streams. Multiple patterns and remote clusters are supported.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/elasticsearch-serverless/api/indices/resolve_index.rb', line 43 def resolve_index(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.resolve_index' } defined_params = [:name].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 'name' missing" unless arguments[:name] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _name = arguments.delete(:name) method = ElasticsearchServerless::API::HTTP_GET path = "_resolve/index/#{Utils.listify(_name)}" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#rollover(arguments = {}) ⇒ Object
Roll over to a new index. TIP: It is recommended to use the index lifecycle rollover action to automate rollovers. The rollover API creates a new index for a data stream or index alias. The API behavior depends on the rollover target. **Roll over a data stream** If you roll over a data stream, the API creates a new write index for the stream. The stream’s previous write index becomes a regular backing index. A rollover also increments the data stream’s generation. **Roll over an index alias with a write index** TIP: Prior to Elasticsearch 7.9, you’d typically use an index alias with a write index to manage time series data. Data streams replace this functionality, require less maintenance, and automatically integrate with data tiers. If an index alias points to multiple indices, one of the indices must be a write index. The rollover API creates a new write index for the alias with is_write_index set to true. The API also sets is_write_index to false for the previous write index. **Roll over an index alias with one index** If you roll over an index alias that points to only one index, the API creates a new index for the alias and removes the original index from the alias. NOTE: A rollover creates a new index and is subject to the wait_for_active_shards setting. **Increment index names for an alias** When you roll over an index alias, you can specify a name for the new index. If you don’t specify a name and the current index ends with - and a number, such as my-index-000001 or my-index-3, the new index name increments that number. For example, if you roll over an alias with a current index of my-index-000001, the rollover creates a new index named my-index-000002. This number is always six characters and zero-padded, regardless of the previous index’s name. If you use an index alias for time series data, you can use date math in the index name to track the rollover date. For example, you can create an alias that points to an index named <my-index-{now/d}-000001>. If you create the index on May 6, 2099, the index’s name is my-index-2099.05.06-000001. If you roll over the alias on May 7, 2099, the new index’s name is my-index-2099.05.07-000002.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/elasticsearch-serverless/api/indices/rollover.rb', line 68 def rollover(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.rollover' } defined_params = [:alias, :new_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 'alias' missing" unless arguments[:alias] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _alias = arguments.delete(:alias) _new_index = arguments.delete(:new_index) method = ElasticsearchServerless::API::HTTP_POST path = if _alias && _new_index "#{Utils.listify(_alias)}/_rollover/#{Utils.listify(_new_index)}" else "#{Utils.listify(_alias)}/_rollover" end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#simulate_index_template(arguments = {}) ⇒ Object
Simulate an index. Get the index configuration that would be applied to the specified index from an existing index template.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/elasticsearch-serverless/api/indices/simulate_index_template.rb', line 35 def simulate_index_template(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.simulate_index_template' } defined_params = [:name].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 'name' missing" unless arguments[:name] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _name = arguments.delete(:name) method = ElasticsearchServerless::API::HTTP_POST path = "_index_template/_simulate_index/#{Utils.listify(_name)}" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#simulate_template(arguments = {}) ⇒ Object
Simulate an index template. Get the index configuration that would be applied by a particular index template.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/elasticsearch-serverless/api/indices/simulate_template.rb', line 38 def simulate_template(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.simulate_template' } defined_params = [:name].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) _name = arguments.delete(:name) method = ElasticsearchServerless::API::HTTP_POST path = if _name "_index_template/_simulate/#{Utils.listify(_name)}" else '_index_template/_simulate' end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#update_aliases(arguments = {}) ⇒ Object
Create or update an alias. Adds a data stream or index to an alias.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/elasticsearch-serverless/api/indices/update_aliases.rb', line 37 def update_aliases(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.update_aliases' } raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) method = ElasticsearchServerless::API::HTTP_POST path = '_aliases' params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#validate_query(arguments = {}) ⇒ Object
Validate a query. Validates a query without running it.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/elasticsearch-serverless/api/indices/validate_query.rb', line 54 def validate_query(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.validate_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? arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = if body ElasticsearchServerless::API::HTTP_POST else ElasticsearchServerless::API::HTTP_GET end path = if _index "#{Utils.listify(_index)}/_validate/query" else '_validate/query' end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |