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

Instance Method Details

#delete(arguments = {}) ⇒ Object

Deletes an async search by ID. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted.

Options Hash (arguments):

  • :id (String)

    A unique identifier for the async search. (Required)

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/elasticsearch-serverless/api/async_search/delete.rb', line 32

def delete(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   = "_async_search/#{Utils.listify(_id)}"
  params = {}

  ElasticsearchServerless::API::Response.new(
    perform_request(method, path, params, body, headers)
  )
end

#get(arguments = {}) ⇒ Object

Retrieves the results of a previously submitted async search request given its ID.

Options Hash (arguments):

  • :id (String)

    A unique identifier for the async search. (Required)

  • :keep_alive (Time)

    Specifies how long the async search should be available in the cluster. When not specified, the keep_alive set with the corresponding submit async request will be used. Otherwise, it is possible to override the value and extend the validity of the request. When this period expires, the search, if still running, is cancelled. If the search is completed, its saved results are deleted.

  • :typed_keys (Boolean)

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

  • :wait_for_completion_timeout (Time)

    Specifies to wait for the search to be completed up until the provided timeout. Final results will be returned if available before the timeout expires, otherwise the currently available results will be returned once the timeout expires. By default no timeout is set meaning that the currently available results will be returned without any additional wait.

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/elasticsearch-serverless/api/async_search/get.rb', line 35

def get(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   = "_async_search/#{Utils.listify(_id)}"
  params = Utils.process_params(arguments)

  ElasticsearchServerless::API::Response.new(
    perform_request(method, path, params, body, headers)
  )
end

#status(arguments = {}) ⇒ Object

Retrieves the status of a previously submitted async search request given its ID.

Options Hash (arguments):

  • :id (String)

    A unique identifier for the async search. (Required)

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/elasticsearch-serverless/api/async_search/status.rb', line 32

def status(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   = "_async_search/status/#{Utils.listify(_id)}"
  params = {}

  ElasticsearchServerless::API::Response.new(
    perform_request(method, path, params, body, headers)
  )
end

#submit(arguments = {}) ⇒ Object

Executes a search request asynchronously.

Options Hash (arguments):

  • :index (String, Array)

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

  • :wait_for_completion_timeout (Time)

    Blocks and waits until the search is completed up to a certain timeout. When the async search completes within the timeout, the response won’t include the ID as the results are not stored in the cluster. Server default: 1s.

  • :keep_on_completion (Boolean)

    If true, results are stored for later retrieval when the search completes within the wait_for_completion_timeout.

  • :keep_alive (Time)

    Specifies how long the async search needs to be available. Ongoing async searches and any saved search results are deleted after this period. Server default: 5d.

  • :allow_no_indices (Boolean)

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

  • :allow_partial_search_results (Boolean)

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

  • :analyzer (String)

    The analyzer to use for the query string

  • :analyze_wildcard (Boolean)

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

  • :batched_reduce_size (Integer)

    Affects how often partial results become available, which happens whenever shard results are reduced. A partial reduction is performed every time the coordinating node has received a certain number of new shard responses (5 by default). Server default: 5.

  • :ccs_minimize_roundtrips (Boolean)

    The default value is the only supported value.

  • :default_operator (String)

    The default operator for query string query (AND or OR)

  • :df (String)

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

  • :docvalue_fields (String, Array<String>)

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

  • :expand_wildcards (String, Array<String>)

    Whether to expand wildcard expression to concrete indices that are open, closed or both.

  • :explain (Boolean)

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

  • :ignore_throttled (Boolean)

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

  • :ignore_unavailable (Boolean)

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

  • :lenient (Boolean)

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

  • :max_concurrent_shard_requests (Integer)

    The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests

  • :min_compatible_shard_node (String)
    TODO
  • :preference (String)

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

  • :pre_filter_shard_size (Integer)

    The default value cannot be changed, which enforces the execution of a pre-filter roundtrip to retrieve statistics from each shard so that the ones that surely don’t hold any document matching the query get skipped. Server default: 1.

  • :request_cache (Boolean)

    Specify if request cache should be used for this request or not, defaults to true Server default: true.

  • :routing (String)

    A comma-separated list of specific routing values

  • :scroll (Time)
    TODO
  • :search_type (String)

    Search operation type

  • :stats (Array<String>)

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

  • :stored_fields (String, Array<String>)

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

  • :suggest_field (String)

    Specifies which field to use for suggestions.

  • :suggest_mode (String)

    Specify suggest mode

  • :suggest_size (Integer)

    How many suggestions to return in response

  • :suggest_text (String)

    The source text for which the suggestions should be returned.

  • :terminate_after (Integer)

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

  • :timeout (Time)

    Explicit operation timeout

  • :track_total_hits (Boolean, Integer)

    Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number.

  • :track_scores (Boolean)

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

  • :typed_keys (Boolean)

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

  • :rest_total_hits_as_int (Boolean)
    TODO
  • :version (Boolean)

    Specify whether to return document version as part of a hit

  • :_source (Boolean, String, Array<String>)

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

  • :_source_excludes (String, Array<String>)

    A list of fields to exclude from the returned _source field

  • :_source_includes (String, Array<String>)

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

  • :seq_no_primary_term (Boolean)

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

  • :q (String)

    Query in the Lucene query string syntax

  • :size (Integer)

    Number of hits to return (default: 10)

  • :from (Integer)

    Starting offset (default: 0)

  • :sort (String)

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

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    request body

See Also:



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/async_search/submit.rb', line 79

def submit(arguments = {})
  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)
  )
end