query

package
v8.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: Apache-2.0 Imports: 11 Imported by: 4

Documentation

Overview

Executes a SQL request

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 NewQuery

type NewQuery func() *Query

NewQuery type alias for index.

func NewQueryFunc

func NewQueryFunc(tp elastictransport.Interface) NewQuery

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

type Query

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

func (*Query) Catalog added in v8.9.0

func (r *Query) Catalog(catalog string) *Query

Catalog Default catalog (cluster) for queries. If unspecified, the queries execute on the data in the local cluster only. API name: catalog

func (*Query) Columnar added in v8.9.0

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

Columnar If true, the results in a columnar fashion: one row represents all the values of a certain column from the current page of results. API name: columnar

func (*Query) Cursor added in v8.9.0

func (r *Query) Cursor(cursor string) *Query

Cursor Cursor used to retrieve a set of paginated results. If you specify a cursor, the API only uses the `columnar` and `time_zone` request body parameters. It ignores other request body parameters. API name: cursor

func (Query) Do

func (r Query) Do(ctx context.Context) (*Response, error)

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

func (*Query) FetchSize added in v8.9.0

func (r *Query) FetchSize(fetchsize int) *Query

FetchSize The maximum number of rows (or entries) to return in one response API name: fetch_size

func (*Query) FieldMultiValueLeniency added in v8.9.0

func (r *Query) FieldMultiValueLeniency(fieldmultivalueleniency bool) *Query

FieldMultiValueLeniency Throw an exception when encountering multiple values for a field (default) or be lenient and return the first value from the list (without any guarantees of what that will be - typically the first in natural ascending order). API name: field_multi_value_leniency

func (*Query) Filter added in v8.9.0

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

Filter Elasticsearch query DSL for additional filtering. API name: filter

func (*Query) Format

func (r *Query) Format(format string) *Query

Format Format for the response. API name: format

func (*Query) Header

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

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

func (*Query) HttpRequest

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

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

func (*Query) IndexUsingFrozen added in v8.9.0

func (r *Query) IndexUsingFrozen(indexusingfrozen bool) *Query

IndexUsingFrozen If true, the search can run on frozen indices. Defaults to false. API name: index_using_frozen

func (*Query) KeepAlive added in v8.9.0

func (r *Query) KeepAlive(duration types.Duration) *Query

KeepAlive Retention period for an async or saved synchronous search. API name: keep_alive

func (*Query) KeepOnCompletion added in v8.9.0

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

KeepOnCompletion If true, Elasticsearch stores synchronous searches if you also specify the wait_for_completion_timeout parameter. If false, Elasticsearch only stores async searches that don’t finish before the wait_for_completion_timeout. API name: keep_on_completion

func (*Query) PageTimeout added in v8.9.0

func (r *Query) PageTimeout(duration types.Duration) *Query

PageTimeout The timeout before a pagination request fails. API name: page_timeout

func (*Query) Params added in v8.9.0

func (r *Query) Params(params map[string]json.RawMessage) *Query

Params Values for parameters in the query. API name: params

func (Query) Perform added in v8.7.0

func (r Query) Perform(ctx context.Context) (*http.Response, error)

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

func (*Query) Query added in v8.9.0

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

Query SQL query to run. API name: query

func (*Query) Raw

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

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

func (*Query) Request

func (r *Query) Request(req *Request) *Query

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

func (*Query) RequestTimeout added in v8.9.0

func (r *Query) RequestTimeout(duration types.Duration) *Query

RequestTimeout The timeout before the request fails. API name: request_timeout

func (*Query) RuntimeMappings added in v8.9.0

func (r *Query) RuntimeMappings(runtimefields types.RuntimeFields) *Query

RuntimeMappings Defines one or more runtime fields in the search request. These fields take precedence over mapped fields with the same name. API name: runtime_mappings

func (*Query) TimeZone added in v8.9.0

func (r *Query) TimeZone(timezone string) *Query

TimeZone ISO-8601 time zone ID for the search. API name: time_zone

func (*Query) WaitForCompletionTimeout added in v8.9.0

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

WaitForCompletionTimeout Period to wait for complete results. Defaults to no timeout, meaning the request waits for complete search results. If the search doesn’t finish within this period, the search becomes async. API name: wait_for_completion_timeout

type Request

type Request struct {

	// Catalog Default catalog (cluster) for queries. If unspecified, the queries execute on
	// the data in the local cluster only.
	Catalog *string `json:"catalog,omitempty"`
	// Columnar If true, the results in a columnar fashion: one row represents all the values
	// of a certain column from the current page of results.
	Columnar *bool `json:"columnar,omitempty"`
	// Cursor Cursor used to retrieve a set of paginated results.
	// If you specify a cursor, the API only uses the `columnar` and `time_zone`
	// request body parameters.
	// It ignores other request body parameters.
	Cursor *string `json:"cursor,omitempty"`
	// FetchSize The maximum number of rows (or entries) to return in one response
	FetchSize *int `json:"fetch_size,omitempty"`
	// FieldMultiValueLeniency Throw an exception when encountering multiple values for a field (default) or
	// be lenient and return the first value from the list (without any guarantees
	// of what that will be - typically the first in natural ascending order).
	FieldMultiValueLeniency *bool `json:"field_multi_value_leniency,omitempty"`
	// Filter Elasticsearch query DSL for additional filtering.
	Filter *types.Query `json:"filter,omitempty"`
	// IndexUsingFrozen If true, the search can run on frozen indices. Defaults to false.
	IndexUsingFrozen *bool `json:"index_using_frozen,omitempty"`
	// KeepAlive Retention period for an async or saved synchronous search.
	KeepAlive types.Duration `json:"keep_alive,omitempty"`
	// KeepOnCompletion If true, Elasticsearch stores synchronous searches if you also specify the
	// wait_for_completion_timeout parameter. If false, Elasticsearch only stores
	// async searches that don’t finish before the wait_for_completion_timeout.
	KeepOnCompletion *bool `json:"keep_on_completion,omitempty"`
	// PageTimeout The timeout before a pagination request fails.
	PageTimeout types.Duration `json:"page_timeout,omitempty"`
	// Params Values for parameters in the query.
	Params map[string]json.RawMessage `json:"params,omitempty"`
	// Query SQL query to run.
	Query *string `json:"query,omitempty"`
	// RequestTimeout The timeout before the request fails.
	RequestTimeout types.Duration `json:"request_timeout,omitempty"`
	// RuntimeMappings Defines one or more runtime fields in the search request. These fields take
	// precedence over mapped fields with the same name.
	RuntimeMappings types.RuntimeFields `json:"runtime_mappings,omitempty"`
	// TimeZone ISO-8601 time zone ID for the search.
	TimeZone *string `json:"time_zone,omitempty"`
	// WaitForCompletionTimeout Period to wait for complete results. Defaults to no timeout, meaning the
	// request waits for complete search results. If the search doesn’t finish
	// within this period, the search becomes async.
	WaitForCompletionTimeout types.Duration `json:"wait_for_completion_timeout,omitempty"`
}

Request holds the request body struct for the package query

https://github.com/elastic/elasticsearch-specification/blob/ac9c431ec04149d9048f2b8f9731e3c2f7f38754/specification/sql/query/QuerySqlRequest.ts#L28-L122

func NewRequest added in v8.5.0

func NewRequest() *Request

NewRequest returns a Request

func (*Request) FromJSON added in v8.5.0

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

FromJSON allows to load an arbitrary json into the request structure

type Response added in v8.7.0

type Response struct {

	// Columns Column headings for the search results. Each object is a column.
	Columns []types.Column `json:"columns,omitempty"`
	// Cursor Cursor for the next set of paginated results. For CSV, TSV, and
	// TXT responses, this value is returned in the `Cursor` HTTP header.
	Cursor *string `json:"cursor,omitempty"`
	// Id Identifier for the search. This value is only returned for async and saved
	// synchronous searches. For CSV, TSV, and TXT responses, this value is returned
	// in the `Async-ID` HTTP header.
	Id *string `json:"id,omitempty"`
	// IsPartial If `true`, the response does not contain complete search results. If
	// `is_partial`
	// is `true` and `is_running` is `true`, the search is still running. If
	// `is_partial`
	// is `true` but `is_running` is `false`, the results are partial due to a
	// failure or
	// timeout. This value is only returned for async and saved synchronous
	// searches.
	// For CSV, TSV, and TXT responses, this value is returned in the
	// `Async-partial` HTTP header.
	IsPartial *bool `json:"is_partial,omitempty"`
	// IsRunning If `true`, the search is still running. If false, the search has finished.
	// This value is only returned for async and saved synchronous searches. For
	// CSV, TSV, and TXT responses, this value is returned in the `Async-partial`
	// HTTP header.
	IsRunning *bool `json:"is_running,omitempty"`
	// Rows Values for the search results.
	Rows [][]json.RawMessage `json:"rows"`
}

func NewResponse added in v8.7.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