Module: ElasticsearchServerless::API::AsyncSearch::Actions
- Defined in:
- lib/elasticsearch-serverless/api/async_search/get.rb,
lib/elasticsearch-serverless/api/async_search/delete.rb,
lib/elasticsearch-serverless/api/async_search/status.rb,
lib/elasticsearch-serverless/api/async_search/submit.rb
Instance Method Summary collapse
-
#delete(arguments = {}) ⇒ Object
Delete an async search.
-
#get(arguments = {}) ⇒ Object
Get async search results.
-
#status(arguments = {}) ⇒ Object
Get the async search status.
-
#submit(arguments = {}) ⇒ Object
Run an async search.
Instance Method Details
#delete(arguments = {}) ⇒ Object
Delete an async search. If the asynchronous search is still running, it is cancelled. Otherwise, the saved search results are deleted. If the Elasticsearch security features are enabled, the deletion of a specific async search is restricted to: the authenticated user that submitted the original search request; users that have the cancel_task
cluster privilege.
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 60 |
# File 'lib/elasticsearch-serverless/api/async_search/delete.rb', line 35 def delete(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || "async_search.delete" } defined_params = [:id].inject({}) do |set_variables, variable| set_variables[variable] = arguments[variable] if arguments.key?(variable) set_variables 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 = ElasticsearchServerless::API::HTTP_DELETE path = "_async_search/#{Utils.listify(_id)}" params = {} ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#get(arguments = {}) ⇒ Object
Get async search results. Retrieve the results of a previously submitted asynchronous search request. If the Elasticsearch security features are enabled, access to the results of a specific async search is restricted to the user or API key that submitted it.
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/async_search/get.rb', line 43 def get(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || "async_search.get" } defined_params = [:id].inject({}) do |set_variables, variable| set_variables[variable] = arguments[variable] if arguments.key?(variable) set_variables 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 = ElasticsearchServerless::API::HTTP_GET path = "_async_search/#{Utils.listify(_id)}" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#status(arguments = {}) ⇒ Object
Get the async search status. Get the status of a previously submitted async search request given its identifier, without retrieving search results. If the Elasticsearch security features are enabled, use of this API is restricted to the monitoring_user
role.
36 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/async_search/status.rb', line 36 def status(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || "async_search.status" } defined_params = [:id].inject({}) do |set_variables, variable| set_variables[variable] = arguments[variable] if arguments.key?(variable) set_variables 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 = ElasticsearchServerless::API::HTTP_GET path = "_async_search/status/#{Utils.listify(_id)}" params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#submit(arguments = {}) ⇒ Object
Run an async search. When the primary sort of the results is an indexed field, shards get sorted based on minimum and maximum value that they hold for that field. Partial results become available following the sort criteria that was requested. Warning: Asynchronous search does not support scroll or search requests that include only the suggest section. By default, Elasticsearch does not allow you to store an async search response larger than 10Mb and an attempt to do this results in an error. The maximum allowed size for a stored async search response can be set by changing the search.max_async_search_response_size
cluster level setting.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/elasticsearch-serverless/api/async_search/submit.rb', line 84 def submit(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || "async_search.submit" } defined_params = [:index].inject({}) do |set_variables, variable| set_variables[variable] = arguments[variable] if arguments.key?(variable) set_variables 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 = ElasticsearchServerless::API::HTTP_POST path = if _index "#{Utils.listify(_index)}/_async_search" else "_async_search" end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |