Module: ElasticsearchServerless::API::Actions
- Included in:
- ElasticsearchServerless::API
- Defined in:
- lib/elasticsearch-serverless/api/get.rb,
lib/elasticsearch-serverless/api/bulk.rb,
lib/elasticsearch-serverless/api/info.rb,
lib/elasticsearch-serverless/api/mget.rb,
lib/elasticsearch-serverless/api/ping.rb,
lib/elasticsearch-serverless/api/count.rb,
lib/elasticsearch-serverless/api/index.rb,
lib/elasticsearch-serverless/api/create.rb,
lib/elasticsearch-serverless/api/delete.rb,
lib/elasticsearch-serverless/api/exists.rb,
lib/elasticsearch-serverless/api/scroll.rb,
lib/elasticsearch-serverless/api/search.rb,
lib/elasticsearch-serverless/api/update.rb,
lib/elasticsearch-serverless/api/explain.rb,
lib/elasticsearch-serverless/api/msearch.rb,
lib/elasticsearch-serverless/api/reindex.rb,
lib/elasticsearch-serverless/api/rank_eval.rb,
lib/elasticsearch-serverless/api/field_caps.rb,
lib/elasticsearch-serverless/api/get_script.rb,
lib/elasticsearch-serverless/api/get_source.rb,
lib/elasticsearch-serverless/api/put_script.rb,
lib/elasticsearch-serverless/api/search_mvt.rb,
lib/elasticsearch-serverless/api/terms_enum.rb,
lib/elasticsearch-serverless/api/termvectors.rb,
lib/elasticsearch-serverless/api/clear_scroll.rb,
lib/elasticsearch-serverless/api/mtermvectors.rb,
lib/elasticsearch-serverless/api/delete_script.rb,
lib/elasticsearch-serverless/api/exists_source.rb,
lib/elasticsearch-serverless/api/delete_by_query.rb,
lib/elasticsearch-serverless/api/search_template.rb,
lib/elasticsearch-serverless/api/update_by_query.rb,
lib/elasticsearch-serverless/api/msearch_template.rb,
lib/elasticsearch-serverless/api/open_point_in_time.rb,
lib/elasticsearch-serverless/api/close_point_in_time.rb,
lib/elasticsearch-serverless/api/render_search_template.rb,
lib/elasticsearch-serverless/api/scripts_painless_execute.rb
Instance Method Summary collapse
-
#bulk(arguments = {}) ⇒ Object
Performs multiple indexing or delete operations in a single API call.
-
#clear_scroll(arguments = {}) ⇒ Object
Clears the search context and results for a scrolling search.
-
#close_point_in_time(arguments = {}) ⇒ Object
Closes a point-in-time.
-
#count(arguments = {}) ⇒ Object
Returns number of documents matching a query.
-
#create(arguments = {}) ⇒ Object
Adds a JSON document to the specified data stream or index and makes it searchable.
-
#delete(arguments = {}) ⇒ Object
Removes a JSON document from the specified index.
-
#delete_by_query(arguments = {}) ⇒ Object
Deletes documents that match the specified query.
-
#delete_script(arguments = {}) ⇒ Object
Deletes a stored script or search template.
-
#exists(arguments = {}) ⇒ Object
(also: #exists?)
Checks if a document in an index exists.
-
#exists_source(arguments = {}) ⇒ Object
(also: #exists_source?)
Checks if a document’s
_sourceis stored. -
#explain(arguments = {}) ⇒ Object
Returns information about why a specific document matches (or doesn’t match) a query.
-
#field_caps(arguments = {}) ⇒ Object
The field capabilities API returns the information about the capabilities of fields among multiple indices.
-
#get(arguments = {}) ⇒ Object
Returns a document.
-
#get_script(arguments = {}) ⇒ Object
Retrieves a stored script or search template.
-
#get_source(arguments = {}) ⇒ Object
Returns the source of a document.
-
#index(arguments = {}) ⇒ Object
Adds a JSON document to the specified data stream or index and makes it searchable.
-
#info(arguments = {}) ⇒ Object
Returns basic information about the cluster.
-
#mget(arguments = {}) ⇒ Object
Allows to get multiple documents in one request.
-
#msearch(arguments = {}) ⇒ Object
Allows to execute several search operations in one request.
-
#msearch_template(arguments = {}) ⇒ Object
Runs multiple templated searches with a single request.
-
#mtermvectors(arguments = {}) ⇒ Object
Returns multiple termvectors in one request.
-
#open_point_in_time(arguments = {}) ⇒ Object
A search request by default executes against the most recent visible data of the target indices, which is called point in time.
-
#ping(arguments = {}) ⇒ Object
Returns whether the cluster is running.
-
#put_script(arguments = {}) ⇒ Object
Creates or updates a stored script or search template.
-
#rank_eval(arguments = {}) ⇒ Object
Enables you to evaluate the quality of ranked search results over a set of typical search queries.
-
#reindex(arguments = {}) ⇒ Object
Allows to copy documents from one index to another, optionally filtering the source documents by a query, changing the destination index settings, or fetching the documents from a remote cluster.
-
#render_search_template(arguments = {}) ⇒ Object
Renders a search template as a search request body.
-
#scripts_painless_execute(arguments = {}) ⇒ Object
Runs a script and returns a result.
-
#scroll(arguments = {}) ⇒ Object
Allows to retrieve a large numbers of results from a single search request.
-
#search(arguments = {}) ⇒ Object
Returns search hits that match the query defined in the request.
-
#search_mvt(arguments = {}) ⇒ Object
Searches a vector tile for geospatial values.
-
#search_template(arguments = {}) ⇒ Object
Runs a search with a search template.
-
#terms_enum(arguments = {}) ⇒ Object
The terms enum API can be used to discover terms in the index that begin with the provided string.
-
#termvector(arguments = {}) ⇒ Object
Deprecated: Use the plural version, #termvectors.
-
#termvectors(arguments = {}) ⇒ Object
Returns information and statistics about terms in the fields of a particular document.
-
#update(arguments = {}) ⇒ Object
Updates a document with a script or partial document.
-
#update_by_query(arguments = {}) ⇒ Object
Updates documents that match the specified query.
Instance Method Details
#bulk(arguments = {}) ⇒ Object
Performs multiple indexing or delete operations in a single API call. This reduces overhead and can greatly increase indexing speed.
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 |
# File 'lib/elasticsearch-serverless/api/bulk.rb', line 42 def bulk(arguments = {}) 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_POST path = if _index "#{Utils.listify(_index)}/_bulk" else "_bulk" end params = Utils.process_params(arguments) if body.is_a? Array payload = ElasticsearchServerless::API::Utils.bulkify(body) else payload = body end headers.merge!("Content-Type" => "application/x-ndjson") ElasticsearchServerless::API::Response.new( perform_request(method, path, params, payload, headers) ) end |
#clear_scroll(arguments = {}) ⇒ Object
Clears the search context and results for a scrolling search.
*Deprecation notice*: A scroll id can be quite large and should be specified as part of the body Deprecated since version 7.0.0
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 64 |
# File 'lib/elasticsearch-serverless/api/clear_scroll.rb', line 37 def clear_scroll(arguments = {}) arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _scroll_id = arguments.delete(:scroll_id) method = ElasticsearchServerless::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 { ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) } else ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end end |
#close_point_in_time(arguments = {}) ⇒ Object
Closes a point-in-time.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/elasticsearch-serverless/api/close_point_in_time.rb', line 31 def close_point_in_time(arguments = {}) arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) method = ElasticsearchServerless::API::HTTP_DELETE path = "_pit" params = {} ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#count(arguments = {}) ⇒ Object
Returns number of documents matching a query.
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/count.rb', line 46 def count(arguments = {}) 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)}/_count" else "_count" end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#create(arguments = {}) ⇒ Object
Adds a JSON document to the specified data stream or index and makes it searchable. If the target is an index and the document already exists, the request updates the document and increments its version.
41 42 43 44 45 46 47 |
# File 'lib/elasticsearch-serverless/api/create.rb', line 41 def create(arguments = {}) if arguments[:id] index arguments.update op_type: 'create' else index arguments end end |
#delete(arguments = {}) ⇒ Object
Removes a JSON document from the specified index.
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 |
# File 'lib/elasticsearch-serverless/api/delete.rb', line 40 def delete(arguments = {}) 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 = ElasticsearchServerless::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 { ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) } else ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end end |
#delete_by_query(arguments = {}) ⇒ Object
Deletes documents that match the specified query.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/elasticsearch-serverless/api/delete_by_query.rb', line 61 def delete_by_query(arguments = {}) 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_POST path = "#{Utils.listify(_index)}/_delete_by_query" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#delete_script(arguments = {}) ⇒ Object
Deletes a stored script or search template.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/elasticsearch-serverless/api/delete_script.rb', line 33 def delete_script(arguments = {}) raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _id = arguments.delete(:id) method = ElasticsearchServerless::API::HTTP_DELETE path = "_scripts/#{Utils.listify(_id)}" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#exists(arguments = {}) ⇒ Object Also known as: exists?
Checks if a document in an index exists.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/elasticsearch-serverless/api/exists.rb', line 42 def exists(arguments = {}) 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 = ElasticsearchServerless::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).status == 200 ? true : false end end |
#exists_source(arguments = {}) ⇒ Object Also known as: exists_source?
Checks if a document’s _source is stored.
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/exists_source.rb', line 41 def exists_source(arguments = {}) 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 = ElasticsearchServerless::API::HTTP_HEAD path = "#{Utils.listify(_index)}/_source/#{Utils.listify(_id)}" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#explain(arguments = {}) ⇒ Object
Returns information about why a specific document matches (or doesn’t match) a query.
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/explain.rb', line 45 def explain(arguments = {}) 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 ElasticsearchServerless::API::HTTP_POST else ElasticsearchServerless::API::HTTP_GET end path = "#{Utils.listify(_index)}/_explain/#{Utils.listify(_id)}" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#field_caps(arguments = {}) ⇒ Object
The field capabilities API returns the information about the capabilities of fields among multiple indices. The field capabilities API returns runtime fields like any other field. For example, a runtime field with a type of keyword is returned as any other field that belongs to the keyword family.
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 |
# File 'lib/elasticsearch-serverless/api/field_caps.rb', line 42 def field_caps(arguments = {}) 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)}/_field_caps" else "_field_caps" end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#get(arguments = {}) ⇒ Object
Returns a document.
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/get.rb', line 43 def get(arguments = {}) 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 = ElasticsearchServerless::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 { ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) } else ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end end |
#get_script(arguments = {}) ⇒ Object
Retrieves a stored script or search template.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/elasticsearch-serverless/api/get_script.rb', line 32 def get_script(arguments = {}) raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _id = arguments.delete(:id) method = ElasticsearchServerless::API::HTTP_GET path = "_scripts/#{Utils.listify(_id)}" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#get_source(arguments = {}) ⇒ Object
Returns the source of a document.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/elasticsearch-serverless/api/get_source.rb', line 42 def get_source(arguments = {}) 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 = ElasticsearchServerless::API::HTTP_GET path = "#{Utils.listify(_index)}/_source/#{Utils.listify(_id)}" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#index(arguments = {}) ⇒ Object
Adds a JSON document to the specified data stream or index and makes it searchable. If the target is an index and the document already exists, the request updates the document and increments its version.
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 |
# File 'lib/elasticsearch-serverless/api/index.rb', line 45 def index(arguments = {}) 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 ? ElasticsearchServerless::API::HTTP_PUT : ElasticsearchServerless::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) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#info(arguments = {}) ⇒ Object
Returns basic information about the cluster.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/elasticsearch-serverless/api/info.rb', line 30 def info(arguments = {}) arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil method = ElasticsearchServerless::API::HTTP_GET path = "" params = {} ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#mget(arguments = {}) ⇒ Object
Allows to get multiple documents in one request.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/elasticsearch-serverless/api/mget.rb', line 41 def mget(arguments = {}) 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_POST path = if _index "#{Utils.listify(_index)}/_mget" else "_mget" end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#msearch(arguments = {}) ⇒ Object
Allows to execute several search operations in one request.
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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/elasticsearch-serverless/api/msearch.rb', line 44 def msearch(arguments = {}) 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_POST path = if _index "#{Utils.listify(_index)}/_msearch" else "_msearch" end params = Utils.process_params(arguments) case when body.is_a?(Array) && body.any? { |d| d.has_key? :search } payload = body .inject([]) do |sum, item| = item data = .delete(:search) sum << sum << data sum end .map { |item| ElasticsearchServerless::API.serializer.dump(item) } payload << "" unless payload.empty? payload = payload.join("\n") when body.is_a?(Array) payload = body.map { |d| d.is_a?(String) ? d : ElasticsearchServerless::API.serializer.dump(d) } payload << "" unless payload.empty? payload = payload.join("\n") else payload = body end headers.merge!("Content-Type" => "application/x-ndjson") ElasticsearchServerless::API::Response.new( perform_request(method, path, params, payload, headers) ) end |
#msearch_template(arguments = {}) ⇒ Object
Runs multiple templated searches with a single request.
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 64 65 66 67 68 69 |
# File 'lib/elasticsearch-serverless/api/msearch_template.rb', line 37 def msearch_template(arguments = {}) 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_POST path = if _index "#{Utils.listify(_index)}/_msearch/template" else "_msearch/template" end params = Utils.process_params(arguments) case when body.is_a?(Array) payload = body.map { |d| d.is_a?(String) ? d : ElasticsearchServerless::API.serializer.dump(d) } payload << "" unless payload.empty? payload = payload.join(" ") else payload = body end headers.merge!("Content-Type" => "application/x-ndjson") ElasticsearchServerless::API::Response.new( perform_request(method, path, params, payload, headers) ) end |
#mtermvectors(arguments = {}) ⇒ Object
Returns multiple termvectors in one request.
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 |
# File 'lib/elasticsearch-serverless/api/mtermvectors.rb', line 44 def mtermvectors(arguments = {}) 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 ElasticsearchServerless::API::HTTP_POST else ElasticsearchServerless::API::HTTP_GET end path = if _index "#{Utils.listify(_index)}/_mtermvectors" else "_mtermvectors" end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#open_point_in_time(arguments = {}) ⇒ Object
A search request by default executes against the most recent visible data of the target indices, which is called point in time. Elasticsearch pit (point in time) is a lightweight view into the state of the data as it existed when initiated. In some cases, it’s preferred to perform multiple search requests using the same point in time. For example, if refreshes happen between search_after requests, then the results of those requests might not be consistent as changes happening between searches are only visible to the more recent point in time.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/elasticsearch-serverless/api/open_point_in_time.rb', line 41 def open_point_in_time(arguments = {}) 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_POST path = "#{Utils.listify(_index)}/_pit" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#ping(arguments = {}) ⇒ Object
Returns whether the cluster is running.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/elasticsearch-serverless/api/ping.rb', line 30 def ping(arguments = {}) arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil method = ElasticsearchServerless::API::HTTP_HEAD path = "" params = {} begin perform_request(method, path, params, body, headers).status == 200 ? true : false rescue Exception => e if e.class.to_s =~ /NotFound|ConnectionFailed/ || e. =~ /Not *Found|404|ConnectionFailed/i false else raise e end end end |
#put_script(arguments = {}) ⇒ Object
Creates or updates a stored script or search 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/put_script.rb', line 35 def put_script(arguments = {}) 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 = ElasticsearchServerless::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) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#rank_eval(arguments = {}) ⇒ Object
Enables you to evaluate the quality of ranked search results over a set of typical search queries.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/elasticsearch-serverless/api/rank_eval.rb', line 36 def rank_eval(arguments = {}) 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_POST path = if _index "#{Utils.listify(_index)}/_rank_eval" else "_rank_eval" end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#reindex(arguments = {}) ⇒ Object
Allows to copy documents from one index to another, optionally filtering the source documents by a query, changing the destination index settings, or fetching the documents from a remote cluster.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/elasticsearch-serverless/api/reindex.rb', line 41 def reindex(arguments = {}) 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 = "_reindex" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#render_search_template(arguments = {}) ⇒ Object
Renders a search template as a search request body.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/elasticsearch-serverless/api/render_search_template.rb', line 32 def render_search_template(arguments = {}) arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _id = arguments.delete(:id) method = if body ElasticsearchServerless::API::HTTP_POST else ElasticsearchServerless::API::HTTP_GET end path = if _id "_render/template/#{Utils.listify(_id)}" else "_render/template" end params = {} ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#scripts_painless_execute(arguments = {}) ⇒ Object
Runs a script and returns a result. 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.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/elasticsearch-serverless/api/scripts_painless_execute.rb', line 35 def scripts_painless_execute(arguments = {}) arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) method = if body ElasticsearchServerless::API::HTTP_POST else ElasticsearchServerless::API::HTTP_GET end path = "_scripts/painless/_execute" params = {} ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#scroll(arguments = {}) ⇒ Object
Allows to retrieve a large numbers of results from a single search request.
*Deprecation notice*: A scroll id can be quite large and should be specified as part of the body Deprecated since version 7.0.0
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/scroll.rb', line 39 def scroll(arguments = {}) arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _scroll_id = arguments.delete(:scroll_id) method = if body ElasticsearchServerless::API::HTTP_POST else ElasticsearchServerless::API::HTTP_GET end path = if _scroll_id "_search/scroll/#{Utils.listify(_scroll_id)}" else "_search/scroll" end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#search(arguments = {}) ⇒ Object
Returns search hits that match the query defined in the request. You can provide search queries using the q query string parameter or the request body. If both are specified, only the query parameter is used.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/elasticsearch-serverless/api/search.rb', line 78 def search(arguments = {}) 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)}/_search" else "_search" end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#search_mvt(arguments = {}) ⇒ Object
Searches a vector tile for geospatial values. Returns results as a binary Mapbox vector tile.
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 72 |
# File 'lib/elasticsearch-serverless/api/search_mvt.rb', line 43 def search_mvt(arguments = {}) raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'field' missing" unless arguments[:field] raise ArgumentError, "Required argument 'zoom' missing" unless arguments[:zoom] raise ArgumentError, "Required argument 'x' missing" unless arguments[:x] raise ArgumentError, "Required argument 'y' missing" unless arguments[:y] 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 = ElasticsearchServerless::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) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#search_template(arguments = {}) ⇒ Object
Runs a search with a search template.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/elasticsearch-serverless/api/search_template.rb', line 45 def search_template(arguments = {}) 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_POST path = if _index "#{Utils.listify(_index)}/_search/template" else "_search/template" end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#terms_enum(arguments = {}) ⇒ Object
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.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/elasticsearch-serverless/api/terms_enum.rb', line 32 def terms_enum(arguments = {}) 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 ElasticsearchServerless::API::HTTP_POST else ElasticsearchServerless::API::HTTP_GET end path = "#{Utils.listify(_index)}/_terms_enum" params = {} ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#termvector(arguments = {}) ⇒ Object
Deprecated: Use the plural version, #termvectors
77 78 79 |
# File 'lib/elasticsearch-serverless/api/termvectors.rb', line 77 def termvector(arguments = {}) termvectors(arguments.merge endpoint: '_termvector') end |
#termvectors(arguments = {}) ⇒ Object
Returns information and statistics about terms in the fields of a particular document.
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 |
# File 'lib/elasticsearch-serverless/api/termvectors.rb', line 44 def termvectors(arguments = {}) 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 ElasticsearchServerless::API::HTTP_POST else ElasticsearchServerless::API::HTTP_GET end endpoint = arguments.delete(:endpoint) || '_termvectors' path = if _index && _id "#{Utils.listify(_index)}/_termvectors/#{Utils.listify(_id)}" else "#{Utils.listify(_index)}/_termvectors" end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |
#update(arguments = {}) ⇒ Object
Updates a document with a script or partial document.
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/update.rb', line 45 def update(arguments = {}) raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _id = arguments.delete(:id) _index = arguments.delete(:index) method = ElasticsearchServerless::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 { ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) } else ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end end |
#update_by_query(arguments = {}) ⇒ Object
Updates documents that match the specified query. If no query is specified, performs an update on every document in the data stream or index without modifying the source, which is useful for picking up mapping changes.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/elasticsearch-serverless/api/update_by_query.rb', line 63 def update_by_query(arguments = {}) 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_POST path = "#{Utils.listify(_index)}/_update_by_query" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers) ) end |