query

package
v8.4.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2022 License: Apache-2.0 Imports: 10 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) Do

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

Do runs the http.Request through the provided transport.

func (*Query) Format

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

Format a short version of the Accept header, e.g. json, yaml 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) Raw

func (r *Query) Raw(raw json.RawMessage) *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.

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 *bool `json:"columnar,omitempty"`

	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 Optional Elasticsearch query DSL for additional filtering.
	Filter *types.QueryContainer `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]interface{} `json:"params,omitempty"`

	// Query SQL query to execute
	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 Time-zone in ISO 8601 used for executing the query on the server. More
	// information available here.
	TimeZone *types.TimeZone `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/1b56d7e58f5c59f05d1641c6d6a8117c5e01d741/specification/sql/query/QuerySqlRequest.ts#L28-L111

type RequestBuilder

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

RequestBuilder is the builder API for the query.Request

func NewRequestBuilder

func NewRequestBuilder() *RequestBuilder

NewRequest returns a RequestBuilder which can be chained and built to retrieve a RequestBuilder

func (*RequestBuilder) Build

func (rb *RequestBuilder) Build() *Request

Build finalize the chain and returns the Request struct.

func (*RequestBuilder) Catalog

func (rb *RequestBuilder) Catalog(catalog string) *RequestBuilder

func (*RequestBuilder) Columnar

func (rb *RequestBuilder) Columnar(columnar bool) *RequestBuilder

func (*RequestBuilder) Cursor

func (rb *RequestBuilder) Cursor(cursor string) *RequestBuilder

func (*RequestBuilder) FetchSize

func (rb *RequestBuilder) FetchSize(fetchsize int) *RequestBuilder

func (*RequestBuilder) FieldMultiValueLeniency

func (rb *RequestBuilder) FieldMultiValueLeniency(fieldmultivalueleniency bool) *RequestBuilder

func (*RequestBuilder) Filter

func (*RequestBuilder) FromJSON

func (rb *RequestBuilder) FromJSON(data string) (*Request, error)

FromJSON allows to load an arbitrary json into the request structure

func (*RequestBuilder) IndexUsingFrozen

func (rb *RequestBuilder) IndexUsingFrozen(indexusingfrozen bool) *RequestBuilder

func (*RequestBuilder) KeepAlive

func (rb *RequestBuilder) KeepAlive(keepalive *types.DurationBuilder) *RequestBuilder

func (*RequestBuilder) KeepOnCompletion

func (rb *RequestBuilder) KeepOnCompletion(keeponcompletion bool) *RequestBuilder

func (*RequestBuilder) PageTimeout

func (rb *RequestBuilder) PageTimeout(pagetimeout *types.DurationBuilder) *RequestBuilder

func (*RequestBuilder) Params

func (rb *RequestBuilder) Params(value map[string]interface{}) *RequestBuilder

func (*RequestBuilder) Query

func (rb *RequestBuilder) Query(query string) *RequestBuilder

func (*RequestBuilder) RequestTimeout

func (rb *RequestBuilder) RequestTimeout(requesttimeout *types.DurationBuilder) *RequestBuilder

func (*RequestBuilder) RuntimeMappings

func (rb *RequestBuilder) RuntimeMappings(runtimemappings *types.RuntimeFieldsBuilder) *RequestBuilder

func (*RequestBuilder) TimeZone

func (rb *RequestBuilder) TimeZone(timezone types.TimeZone) *RequestBuilder

func (*RequestBuilder) WaitForCompletionTimeout

func (rb *RequestBuilder) WaitForCompletionTimeout(waitforcompletiontimeout *types.DurationBuilder) *RequestBuilder

Jump to

Keyboard shortcuts

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