asyncquery

package
v8.18.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2025 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Overview

Run an async ES|QL query. Asynchronously run an ES|QL (Elasticsearch query language) query, monitor its progress, and retrieve results when they become available.

The API accepts the same parameters and request body as the synchronous query API, along with additional async related properties.

Index

Constants

This section is empty.

Variables

View Source
var ErrBuildPath = errors.New("cannot build path, check for missing path parameters")

ErrBuildPath is returned in case of missing parameters within the build of the request.

Functions

This section is empty.

Types

type AsyncQuery

type AsyncQuery struct {
	// contains filtered or unexported fields
}

func New

Run an async ES|QL query. Asynchronously run an ES|QL (Elasticsearch query language) query, monitor its progress, and retrieve results when they become available.

The API accepts the same parameters and request body as the synchronous query API, along with additional async related properties.

https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-async-query-api.html

func (*AsyncQuery) Columnar added in v8.18.0

func (r *AsyncQuery) Columnar(columnar bool) *AsyncQuery

Columnar By default, ES|QL returns results as rows. For example, FROM returns each individual document as one row. For the JSON, YAML, CBOR and smile formats, ES|QL can return the results in a columnar fashion where one row represents all the values of a certain column in the results. API name: columnar

func (*AsyncQuery) Delimiter added in v8.18.0

func (r *AsyncQuery) Delimiter(delimiter string) *AsyncQuery

Delimiter The character to use between values within a CSV row. It is valid only for the CSV format. API name: delimiter

func (AsyncQuery) Do

func (r AsyncQuery) Do(providedCtx context.Context) (Response, error)

Do runs the request through the transport, handle the response and returns a asyncquery.Response

func (*AsyncQuery) DropNullColumns added in v8.18.0

func (r *AsyncQuery) DropNullColumns(dropnullcolumns bool) *AsyncQuery

DropNullColumns Indicates whether columns that are entirely `null` will be removed from the `columns` and `values` portion of the results. If `true`, the response will include an extra section under the name `all_columns` which has the name of all the columns. API name: drop_null_columns

func (*AsyncQuery) ErrorTrace added in v8.18.0

func (r *AsyncQuery) ErrorTrace(errortrace bool) *AsyncQuery

ErrorTrace When set to `true` Elasticsearch will include the full stack trace of errors when they occur. API name: error_trace

func (*AsyncQuery) Filter added in v8.18.0

func (r *AsyncQuery) Filter(filter *types.Query) *AsyncQuery

Filter Specify a Query DSL query in the filter parameter to filter the set of documents that an ES|QL query runs on. API name: filter

func (*AsyncQuery) FilterPath added in v8.18.0

func (r *AsyncQuery) FilterPath(filterpaths ...string) *AsyncQuery

FilterPath Comma-separated list of filters in dot notation which reduce the response returned by Elasticsearch. API name: filter_path

func (*AsyncQuery) Format added in v8.18.0

func (r *AsyncQuery) Format(format esqlformat.EsqlFormat) *AsyncQuery

Format A short version of the Accept header, for example `json` or `yaml`. API name: format

func (*AsyncQuery) Header

func (r *AsyncQuery) Header(key, value string) *AsyncQuery

Header set a key, value pair in the AsyncQuery headers map.

func (*AsyncQuery) HttpRequest

func (r *AsyncQuery) HttpRequest(ctx context.Context) (*http.Request, error)

HttpRequest returns the http.Request object built from the given parameters.

func (*AsyncQuery) Human added in v8.18.0

func (r *AsyncQuery) Human(human bool) *AsyncQuery

Human When set to `true` will return statistics in a format suitable for humans. For example `"exists_time": "1h"` for humans and `"eixsts_time_in_millis": 3600000` for computers. When disabled the human readable values will be omitted. This makes sense for responses being consumed only by machines. API name: human

func (*AsyncQuery) IncludeCcsMetadata added in v8.18.0

func (r *AsyncQuery) IncludeCcsMetadata(includeccsmetadata bool) *AsyncQuery

IncludeCcsMetadata When set to `true` and performing a cross-cluster query, the response will include an extra `_clusters` object with information about the clusters that participated in the search along with info such as shards count. API name: include_ccs_metadata

func (*AsyncQuery) KeepAlive added in v8.18.0

func (r *AsyncQuery) KeepAlive(duration string) *AsyncQuery

KeepAlive The period for which the query and its results are stored in the cluster. The default period is five days. When this period expires, the query and its results are deleted, even if the query is still ongoing. If the `keep_on_completion` parameter is false, Elasticsearch only stores async queries that do not complete within the period set by the `wait_for_completion_timeout` parameter, regardless of this value. API name: keep_alive

func (*AsyncQuery) KeepOnCompletion added in v8.18.0

func (r *AsyncQuery) KeepOnCompletion(keeponcompletion bool) *AsyncQuery

KeepOnCompletion Indicates whether the query and its results are stored in the cluster. If false, the query and its results are stored in the cluster only if the request does not complete during the period set by the `wait_for_completion_timeout` parameter. API name: keep_on_completion

func (*AsyncQuery) Locale added in v8.18.0

func (r *AsyncQuery) Locale(locale string) *AsyncQuery

API name: locale

func (*AsyncQuery) Params added in v8.18.0

func (r *AsyncQuery) Params(params ...types.FieldValue) *AsyncQuery

Params To avoid any attempts of hacking or code injection, extract the values in a separate list of parameters. Use question mark placeholders (?) in the query string for each of the parameters. API name: params

func (AsyncQuery) Perform

func (r AsyncQuery) Perform(providedCtx context.Context) (*http.Response, error)

Perform runs the http.Request through the provided transport and returns an http.Response.

func (*AsyncQuery) Pretty added in v8.18.0

func (r *AsyncQuery) Pretty(pretty bool) *AsyncQuery

Pretty If set to `true` the returned JSON will be "pretty-formatted". Only use this option for debugging only. API name: pretty

func (*AsyncQuery) Profile added in v8.18.0

func (r *AsyncQuery) Profile(profile bool) *AsyncQuery

Profile If provided and `true` the response will include an extra `profile` object with information on how the query was executed. This information is for human debugging and its format can change at any time but it can give some insight into the performance of each part of the query. API name: profile

func (*AsyncQuery) Query added in v8.18.0

func (r *AsyncQuery) Query(query string) *AsyncQuery

Query The ES|QL query API accepts an ES|QL query string in the query parameter, runs it, and returns the results. API name: query

func (*AsyncQuery) Raw added in v8.18.0

func (r *AsyncQuery) Raw(raw io.Reader) *AsyncQuery

Raw takes a json payload as input which is then passed to the http.Request If specified Raw takes precedence on Request method.

func (*AsyncQuery) Request added in v8.18.0

func (r *AsyncQuery) Request(req *Request) *AsyncQuery

Request allows to set the request property with the appropriate payload.

func (*AsyncQuery) Tables added in v8.18.0

func (r *AsyncQuery) Tables(tables map[string]map[string]types.TableValuesContainer) *AsyncQuery

Tables Tables to use with the LOOKUP operation. The top level key is the table name and the next level key is the column name. API name: tables

func (*AsyncQuery) WaitForCompletionTimeout added in v8.18.0

func (r *AsyncQuery) WaitForCompletionTimeout(duration types.Duration) *AsyncQuery

WaitForCompletionTimeout The period to wait for the request to finish. By default, the request waits for 1 second for the query results. If the query completes during this period, results are returned Otherwise, a query ID is returned that can later be used to retrieve the results. API name: wait_for_completion_timeout

type NewAsyncQuery

type NewAsyncQuery func() *AsyncQuery

NewAsyncQuery type alias for index.

func NewAsyncQueryFunc

func NewAsyncQueryFunc(tp elastictransport.Interface) NewAsyncQuery

NewAsyncQueryFunc returns a new instance of AsyncQuery with the provided transport. Used in the index of the library this allows to retrieve every apis in once place.

type Request added in v8.18.0

type Request struct {

	// Columnar By default, ES|QL returns results as rows. For example, FROM returns each
	// individual document as one row. For the JSON, YAML, CBOR and smile formats,
	// ES|QL can return the results in a columnar fashion where one row represents
	// all the values of a certain column in the results.
	Columnar *bool `json:"columnar,omitempty"`
	// Filter Specify a Query DSL query in the filter parameter to filter the set of
	// documents that an ES|QL query runs on.
	Filter *types.Query `json:"filter,omitempty"`
	// IncludeCcsMetadata When set to `true` and performing a cross-cluster query, the response will
	// include an extra `_clusters`
	// object with information about the clusters that participated in the search
	// along with info such as shards
	// count.
	IncludeCcsMetadata *bool   `json:"include_ccs_metadata,omitempty"`
	Locale             *string `json:"locale,omitempty"`
	// Params To avoid any attempts of hacking or code injection, extract the values in a
	// separate list of parameters. Use question mark placeholders (?) in the query
	// string for each of the parameters.
	Params []types.FieldValue `json:"params,omitempty"`
	// Profile If provided and `true` the response will include an extra `profile` object
	// with information on how the query was executed. This information is for human
	// debugging
	// and its format can change at any time but it can give some insight into the
	// performance
	// of each part of the query.
	Profile *bool `json:"profile,omitempty"`
	// Query The ES|QL query API accepts an ES|QL query string in the query parameter,
	// runs it, and returns the results.
	Query string `json:"query"`
	// Tables Tables to use with the LOOKUP operation. The top level key is the table
	// name and the next level key is the column name.
	Tables map[string]map[string]types.TableValuesContainer `json:"tables,omitempty"`
	// WaitForCompletionTimeout The period to wait for the request to finish.
	// By default, the request waits for 1 second for the query results.
	// If the query completes during this period, results are returned
	// Otherwise, a query ID is returned that can later be used to retrieve the
	// results.
	WaitForCompletionTimeout types.Duration `json:"wait_for_completion_timeout,omitempty"`
}

Request holds the request body struct for the package asyncquery

https://github.com/elastic/elasticsearch-specification/blob/3a94b6715915b1e9311724a2614c643368eece90/specification/esql/async_query/AsyncQueryRequest.ts#L28-L133

func NewRequest added in v8.18.0

func NewRequest() *Request

NewRequest returns a Request

func (*Request) FromJSON added in v8.18.0

func (r *Request) FromJSON(data string) (*Request, error)

FromJSON allows to load an arbitrary json into the request structure

func (*Request) UnmarshalJSON added in v8.18.0

func (s *Request) UnmarshalJSON(data []byte) error

type Response added in v8.18.0

type Response = []byte

func NewResponse added in v8.18.0

func NewResponse() Response

NewResponse returns a Response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL