Module: Elasticsearch::API::Esql::Actions

Included in:
EsqlClient
Defined in:
lib/elasticsearch/api/namespace/esql.rb,
lib/elasticsearch/api/actions/esql/query.rb,
lib/elasticsearch/api/actions/esql/async_query.rb,
lib/elasticsearch/api/actions/esql/async_query_get.rb,
lib/elasticsearch/api/actions/esql/async_query_stop.rb,
lib/elasticsearch/api/actions/esql/async_query_delete.rb

Instance Method Summary collapse

Instance Method Details

#async_query(arguments = {}) ⇒ Object

Run an async ES|QL query

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :format (String)

    A short version of the Accept header, e.g. json, yaml. ‘csv`, `tsv`, and `txt` formats will return results in a tabular format, excluding other metadata fields from the response. For async requests, nothing will be returned if the async query doesn’t finish within the timeout. The query ID and running status are available in the ‘X-Elasticsearch-Async-Id` and `X-Elasticsearch-Async-Is-Running` HTTP headers of the response, respectively. (options: csv, json, tsv, txt, yaml, cbor, smile, arrow)

  • :delimiter (String)

    The character to use between values within a CSV row. Only valid for the csv format.

  • :drop_null_columns (Boolean)

    Should entirely null columns be removed from the results? Their name and type will be returning in a new ‘all_columns` section.

  • :allow_partial_results (Boolean)

    If ‘true`, partial results will be returned if there are shard failures, but the query can continue to execute on other clusters and shards. If `false`, the entire query will fail if there are any failures.

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    Use the ‘query` element to start a query. Use `columnar` to format the answer. (Required)

Raises:

  • (ArgumentError)

See Also:



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/elasticsearch/api/actions/esql/async_query.rb', line 36

def async_query(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'esql.async_query' }

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

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

  body   = arguments.delete(:body)

  method = Elasticsearch::API::HTTP_POST
  path   = '_query/async'
  params = Utils.process_params(arguments)

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

#async_query_delete(arguments = {}) ⇒ Object

Delete an async ES|QL query

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    The async query 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/esql/async_query_delete.rb', line 32

def async_query_delete(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'esql.async_query_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   = "_query/async/#{Utils.__listify(_id)}"
  params = {}

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

#async_query_get(arguments = {}) ⇒ Object

Get async ES|QL query results

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    The async query ID

  • :format (String)

    A short version of the Accept header, for example ‘json` or `yaml`. (options: csv, json, tsv, txt, yaml, cbor, smile, arrow)

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

  • :drop_null_columns (Boolean)

    Should entirely null columns be removed from the results? Their name and type will be returning in a new ‘all_columns` section.

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



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/api/actions/esql/async_query_get.rb', line 36

def async_query_get(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'esql.async_query_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   = "_query/async/#{Utils.__listify(_id)}"
  params = Utils.process_params(arguments)

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

#async_query_stop(arguments = {}) ⇒ Object

Stop async ES|QL query

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    The async query ID

  • :drop_null_columns (Boolean)

    Indicates whether columns that are entirely ‘null` will be removed from the `columns` and `values` portion of the results.

  • :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/esql/async_query_stop.rb', line 33

def async_query_stop(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'esql.async_query_stop' }

  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_POST
  path   = "_query/async/#{Utils.__listify(_id)}/stop"
  params = Utils.process_params(arguments)

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

#query(arguments = {}) ⇒ Object

Run an ES|QL query

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :format (String)

    A short version of the Accept header, e.g. json, yaml. ‘csv`, `tsv`, and `txt` formats will return results in a tabular format, excluding other metadata fields from the response. (options: csv, json, tsv, txt, yaml, cbor, smile, arrow)

  • :delimiter (String)

    The character to use between values within a CSV row. Only valid for the csv format.

  • :drop_null_columns (Boolean)

    Should entirely null columns be removed from the results? Their name and type will be returning in a new ‘all_columns` section.

  • :allow_partial_results (Boolean)

    If ‘true`, partial results will be returned if there are shard failures, but the query can continue to execute on other clusters and shards. If `false`, the entire query will fail if there are any failures.

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    Use the ‘query` element to start a query. Use `columnar` to format the answer. (Required)

Raises:

  • (ArgumentError)

See Also:



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/elasticsearch/api/actions/esql/query.rb', line 36

def query(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'esql.query' }

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

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

  body   = arguments.delete(:body)

  method = Elasticsearch::API::HTTP_POST
  path   = '_query'
  params = Utils.process_params(arguments)

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