Module: Elasticsearch::API::AsyncSearch::Actions

Included in:
AsyncSearchClient
Defined in:
lib/elasticsearch/api/namespace/async_search.rb,
lib/elasticsearch/api/actions/async_search/get.rb,
lib/elasticsearch/api/actions/async_search/delete.rb,
lib/elasticsearch/api/actions/async_search/status.rb,
lib/elasticsearch/api/actions/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.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    The async search ID

  • :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
50
51
52
53
54
55
56
# File 'lib/elasticsearch/api/actions/async_search/delete.rb', line 32

def delete(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'async_search.delete' }

  defined_params = [:id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _id = arguments.delete(:id)

  method = Elasticsearch::API::HTTP_DELETE
  path   = "_async_search/#{Utils.__listify(_id)}"
  params = {}

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

#get(arguments = {}) ⇒ Object

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    The async search ID

  • :wait_for_completion_timeout (Time)

    Specify the time that the request should block waiting for the final response

  • :keep_alive (Time)

    Specify the time interval in which the results (partial or final) for this search will be available

  • :typed_keys (Boolean)

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

  • :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
53
54
55
56
57
58
59
# File 'lib/elasticsearch/api/actions/async_search/get.rb', line 35

def get(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'async_search.get' }

  defined_params = [:id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _id = arguments.delete(:id)

  method = Elasticsearch::API::HTTP_GET
  path   = "_async_search/#{Utils.__listify(_id)}"
  params = Utils.process_params(arguments)

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

#status(arguments = {}) ⇒ Object

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

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    The async search ID

  • :keep_alive (Time)

    Specify the time interval in which the results (partial or final) for this search will be available

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



33
34
35
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/api/actions/async_search/status.rb', line 33

def status(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'async_search.status' }

  defined_params = [:id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _id = arguments.delete(:id)

  method = Elasticsearch::API::HTTP_GET
  path   = "_async_search/status/#{Utils.__listify(_id)}"
  params = Utils.process_params(arguments)

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

#submit(arguments = {}) ⇒ Object

Executes a search request asynchronously.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :index (List)

    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)

    Specify the time that the request should block waiting for the final response

  • :keep_on_completion (Boolean)

    Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false)

  • :keep_alive (Time)

    Update the time interval in which the results (partial or final) for this search will be available

  • :batched_reduce_size (Number)

    The number of shard results that should be reduced at once on the coordinating node. This value should be used as the granularity at which progress results will be made available.

  • :request_cache (Boolean)

    Specify if request cache should be used for this request or not, defaults to true

  • :analyzer (String)

    The analyzer to use for the query string

  • :analyze_wildcard (Boolean)

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

  • :default_operator (String)

    The default operator for query string query (AND or OR) (options: AND, OR)

  • :df (String)

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

  • :explain (Boolean)

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

  • :stored_fields (List)

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

  • :docvalue_fields (List)

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

  • :from (Number)

    Starting offset (default: 0)

  • :ignore_unavailable (Boolean)

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

  • :ignore_throttled (Boolean)

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

  • :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)

  • :expand_wildcards (String)

    Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)

  • :lenient (Boolean)

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

  • :preference (String)

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

  • :q (String)

    Query in the Lucene query string syntax

  • :routing (List)

    A comma-separated list of specific routing values

  • :search_type (String)

    Search operation type (options: query_then_fetch, dfs_query_then_fetch)

  • :size (Number)

    Number of hits to return (default: 10)

  • :sort (List)

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

  • :_source (List)

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

  • :_source_excludes (List)

    A list of fields to exclude from the returned _source field

  • :_source_includes (List)

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

  • :terminate_after (Number)

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

  • :stats (List)

    Specific β€˜tag’ of the request for logging and statistical purposes

  • :suggest_field (String)

    Specify which field to use for suggestions

  • :suggest_mode (String)

    Specify suggest mode (options: missing, popular, always)

  • :suggest_size (Number)

    How many suggestions to return in response

  • :suggest_text (String)

    The source text for which the suggestions should be returned

  • :timeout (Time)

    Explicit operation timeout

  • :track_scores (Boolean)

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

  • :track_total_hits (Boolean|long)

    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.

  • :allow_partial_search_results (Boolean)

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

  • :typed_keys (Boolean)

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

  • :version (Boolean)

    Specify whether to return document version as part of a hit

  • :seq_no_primary_term (Boolean)

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

  • :max_concurrent_shard_requests (Number)

    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

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The search definition using the Query DSL

See Also:



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
99
100
# File 'lib/elasticsearch/api/actions/async_search/submit.rb', line 74

def submit(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'async_search.submit' }

  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 = Elasticsearch::API::HTTP_POST
  path   = if _index
             "#{Utils.__listify(_index)}/_async_search"
           else
             '_async_search'
           end
  params = Utils.process_params(arguments)

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