Movatterモバイル変換


[0]ホーム

URL:


Notice  The highest tagged major version isv9.

query

package
v8.19.1Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License:Apache-2.0Imports:13Imported by:4

Details

Repository

github.com/elastic/go-elasticsearch

Links

Documentation

Overview

Get SQL search results.Run an 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

typeNewQuery

type NewQuery func() *Query

NewQuery type alias for index.

funcNewQueryFunc

func NewQueryFunc(tpelastictransport.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.

typeQuery

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

func (*Query)AllowPartialSearchResultsadded inv8.18.0

func (r *Query) AllowPartialSearchResults(allowpartialsearchresultsbool) *Query

AllowPartialSearchResults If `true`, the response has partial results when there are shard requesttimeouts or shard failures.If `false`, the API returns an error with no partial results.API name: allow_partial_search_results

func (*Query)Catalogadded inv8.9.0

func (r *Query) Catalog(catalogstring) *Query

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

func (*Query)Columnaradded inv8.9.0

func (r *Query) Columnar(columnarbool) *Query

Columnar If `true`, the results are in a columnar fashion: one row represents all thevalues of a certain column from the current page of results.The API supports this parameter only for CBOR, JSON, SMILE, and YAMLresponses.API name: columnar

func (*Query)Cursoradded inv8.9.0

func (r *Query) Cursor(cursorstring) *Query

Cursor The 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 (rQuery) Do(providedCtxcontext.Context) (*Response,error)

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

func (*Query)ErrorTraceadded inv8.14.0

func (r *Query) ErrorTrace(errortracebool) *Query

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

func (*Query)FetchSizeadded inv8.9.0

func (r *Query) FetchSize(fetchsizeint) *Query

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

func (*Query)FieldMultiValueLeniencyadded inv8.9.0

func (r *Query) FieldMultiValueLeniency(fieldmultivalueleniencybool) *Query

FieldMultiValueLeniency If `false`, the API returns an exception when encountering multiple valuesfor a field.If `true`, the API is lenient and returns the first value from the array withno guarantee of consistent results.API name: field_multi_value_leniency

func (*Query)Filteradded inv8.9.0

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

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

func (*Query)FilterPathadded inv8.14.0

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

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

func (*Query)Format

func (r *Query) Format(formatsqlformat.SqlFormat) *Query

Format The format for the response.You can also specify a format using the `Accept` HTTP header.If you specify both this parameter and the `Accept` HTTP header, thisparameter takes precedence.API name: format

func (*Query)Header

func (r *Query) Header(key, valuestring) *Query

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

func (*Query)HttpRequest

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

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

func (*Query)Humanadded inv8.14.0

func (r *Query) Human(humanbool) *Query

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 humanreadable values will be omitted. This makes sense for responses beingconsumedonly by machines.API name: human

func (*Query)IndexUsingFrozenadded inv8.9.0

func (r *Query) IndexUsingFrozen(indexusingfrozenbool) *Query

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

func (*Query)KeepAliveadded inv8.9.0

func (r *Query) KeepAlive(durationtypes.Duration) *Query

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

func (*Query)KeepOnCompletionadded inv8.9.0

func (r *Query) KeepOnCompletion(keeponcompletionbool) *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 beforethe `wait_for_completion_timeout`.API name: keep_on_completion

func (*Query)PageTimeoutadded inv8.9.0

func (r *Query) PageTimeout(durationtypes.Duration) *Query

PageTimeout The minimum retention period for the scroll cursor.After this time period, a pagination request might fail because the scrollcursor is no longer available.Subsequent scroll requests prolong the lifetime of the scroll cursor by theduration of `page_timeout` in the scroll request.API name: page_timeout

func (*Query)Paramsadded inv8.9.0

func (r *Query) Params(params ...json.RawMessage) *Query

Params The values for parameters in the query.API name: params

func (Query)Performadded inv8.7.0

func (rQuery) Perform(providedCtxcontext.Context) (*http.Response,error)

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

func (*Query)Prettyadded inv8.14.0

func (r *Query) Pretty(prettybool) *Query

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

func (*Query)Queryadded inv8.9.0

func (r *Query) Query(querystring) *Query

Query The SQL query to run.API name: query

func (*Query)Raw

func (r *Query) Raw(rawio.Reader) *Query

Raw takes a json payload as input which is then passed to the http.RequestIf 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)RequestTimeoutadded inv8.9.0

func (r *Query) RequestTimeout(durationtypes.Duration) *Query

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

func (*Query)RuntimeMappingsadded inv8.9.0

func (r *Query) RuntimeMappings(runtimefieldstypes.RuntimeFields) *Query

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

func (*Query)TimeZoneadded inv8.9.0

func (r *Query) TimeZone(timezonestring) *Query

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

func (*Query)WaitForCompletionTimeoutadded inv8.9.0

func (r *Query) WaitForCompletionTimeout(durationtypes.Duration) *Query

WaitForCompletionTimeout The period to wait for complete results.It defaults to no timeout, meaning the request waits for complete searchresults.If the search doesn't finish within this period, the search becomes async.

To save a synchronous search, you must specify this parameter and the`keep_on_completion` parameter.API name: wait_for_completion_timeout

typeRequest

type Request struct {// AllowPartialSearchResults If `true`, the response has partial results when there are shard request// timeouts or shard failures.// If `false`, the API returns an error with no partial results.AllowPartialSearchResults *bool `json:"allow_partial_search_results,omitempty"`// Catalog The 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 are in a columnar fashion: one row represents all the// values of a certain column from the current page of results.// The API supports this parameter only for CBOR, JSON, SMILE, and YAML// responses.Columnar *bool `json:"columnar,omitempty"`// Cursor The 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 If `false`, the API returns an exception when encountering multiple values// for a field.// If `true`, the API is lenient and returns the first value from the array with// no guarantee of consistent results.FieldMultiValueLeniency *bool `json:"field_multi_value_leniency,omitempty"`// Filter The Elasticsearch query DSL for additional filtering.Filter *types.Query `json:"filter,omitempty"`// IndexUsingFrozen If `true`, the search can run on frozen indices.IndexUsingFrozen *bool `json:"index_using_frozen,omitempty"`// KeepAlive The retention period for an async or saved synchronous search.KeepAlivetypes.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 minimum retention period for the scroll cursor.// After this time period, a pagination request might fail because the scroll// cursor is no longer available.// Subsequent scroll requests prolong the lifetime of the scroll cursor by the// duration of `page_timeout` in the scroll request.PageTimeouttypes.Duration `json:"page_timeout,omitempty"`// Params The values for parameters in the query.Params []json.RawMessage `json:"params,omitempty"`// Query The SQL query to run.Query *string `json:"query,omitempty"`// RequestTimeout The timeout before the request fails.RequestTimeouttypes.Duration `json:"request_timeout,omitempty"`// RuntimeMappings One or more runtime fields for the search request.// These fields take precedence over mapped fields with the same name.RuntimeMappingstypes.RuntimeFields `json:"runtime_mappings,omitempty"`// TimeZone The ISO-8601 time zone ID for the search.TimeZone *string `json:"time_zone,omitempty"`// WaitForCompletionTimeout The period to wait for complete results.// It 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.//// To save a synchronous search, you must specify this parameter and the// `keep_on_completion` parameter.WaitForCompletionTimeouttypes.Duration `json:"wait_for_completion_timeout,omitempty"`}

Request holds the request body struct for the package query

https://github.com/elastic/elasticsearch-specification/blob/470b4b9aaaa25cae633ec690e54b725c6fc939c7/specification/sql/query/QuerySqlRequest.ts#L27-L151

funcNewRequestadded inv8.5.0

func NewRequest() *Request

NewRequest returns a Request

func (*Request)FromJSONadded inv8.5.0

func (r *Request) FromJSON(datastring) (*Request,error)

FromJSON allows to load an arbitrary json into the request structure

func (*Request)UnmarshalJSONadded inv8.12.1

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

typeResponseadded inv8.7.0

type Response struct {// Columns Column headings for the search results. Each object is a column.Columns []types.Column `json:"columns,omitempty"`// Cursor The 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 The identifier for the search.// This value is returned only 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 returned only 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 returned only 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 The values for the search results.Rows [][]json.RawMessage `json:"rows"`}

Response holds the response body struct for the package query

https://github.com/elastic/elasticsearch-specification/blob/470b4b9aaaa25cae633ec690e54b725c6fc939c7/specification/sql/query/QuerySqlResponse.ts#L23-L60

funcNewResponseadded inv8.7.0

func NewResponse() *Response

NewResponse returns a Response

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp