searchtemplate

package
v8.13.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 14 Imported by: 3

Documentation

Overview

Allows to use the Mustache language to pre-render a search definition.

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 NewSearchTemplate

type NewSearchTemplate func() *SearchTemplate

NewSearchTemplate type alias for index.

func NewSearchTemplateFunc

func NewSearchTemplateFunc(tp elastictransport.Interface) NewSearchTemplate

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

type Request

type Request struct {

	// Explain If `true`, returns detailed information about score calculation as part of
	// each hit.
	Explain *bool `json:"explain,omitempty"`
	// Id ID of the search template to use. If no source is specified,
	// this parameter is required.
	Id *string `json:"id,omitempty"`
	// Params Key-value pairs used to replace Mustache variables in the template.
	// The key is the variable name.
	// The value is the variable value.
	Params map[string]json.RawMessage `json:"params,omitempty"`
	// Profile If `true`, the query execution is profiled.
	Profile *bool `json:"profile,omitempty"`
	// Source An inline search template. Supports the same parameters as the search API's
	// request body. Also supports Mustache variables. If no id is specified, this
	// parameter is required.
	Source *string `json:"source,omitempty"`
}

Request holds the request body struct for the package searchtemplate

https://github.com/elastic/elasticsearch-specification/blob/5bf86339cd4bda77d07f6eaa6789b72f9c0279b1/specification/_global/search_template/SearchTemplateRequest.ts#L32-L134

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

func (*Request) UnmarshalJSON added in v8.12.1

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

type Response added in v8.7.0

type Response struct {
	Aggregations    map[string]types.Aggregate `json:"aggregations,omitempty"`
	Clusters_       *types.ClusterStatistics   `json:"_clusters,omitempty"`
	Fields          map[string]json.RawMessage `json:"fields,omitempty"`
	Hits            types.HitsMetadata         `json:"hits"`
	MaxScore        *types.Float64             `json:"max_score,omitempty"`
	NumReducePhases *int64                     `json:"num_reduce_phases,omitempty"`
	PitId           *string                    `json:"pit_id,omitempty"`
	Profile         *types.Profile             `json:"profile,omitempty"`
	ScrollId_       *string                    `json:"_scroll_id,omitempty"`
	Shards_         types.ShardStatistics      `json:"_shards"`
	Suggest         map[string][]types.Suggest `json:"suggest,omitempty"`
	TerminatedEarly *bool                      `json:"terminated_early,omitempty"`
	TimedOut        bool                       `json:"timed_out"`
	Took            int64                      `json:"took"`
}

Response holds the response body struct for the package searchtemplate

https://github.com/elastic/elasticsearch-specification/blob/5bf86339cd4bda77d07f6eaa6789b72f9c0279b1/specification/_global/search_template/SearchTemplateResponse.ts#L30-L48

func NewResponse added in v8.7.0

func NewResponse() *Response

NewResponse returns a Response

func (*Response) UnmarshalJSON added in v8.7.0

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

type SearchTemplate

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

func New

Allows to use the Mustache language to pre-render a search definition.

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html

func (*SearchTemplate) AllowNoIndices

func (r *SearchTemplate) AllowNoIndices(allownoindices bool) *SearchTemplate

AllowNoIndices If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. API name: allow_no_indices

func (*SearchTemplate) CcsMinimizeRoundtrips

func (r *SearchTemplate) CcsMinimizeRoundtrips(ccsminimizeroundtrips bool) *SearchTemplate

CcsMinimizeRoundtrips If `true`, network round-trips are minimized for cross-cluster search requests. API name: ccs_minimize_roundtrips

func (SearchTemplate) Do

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

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

func (*SearchTemplate) ExpandWildcards

func (r *SearchTemplate) ExpandWildcards(expandwildcards ...expandwildcard.ExpandWildcard) *SearchTemplate

ExpandWildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`. API name: expand_wildcards

func (*SearchTemplate) Explain

func (r *SearchTemplate) Explain(explain bool) *SearchTemplate

Explain If `true`, returns detailed information about score calculation as part of each hit. API name: explain

func (*SearchTemplate) Header

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

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

func (*SearchTemplate) HttpRequest

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

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

func (*SearchTemplate) Id added in v8.9.0

Id ID of the search template to use. If no source is specified, this parameter is required. API name: id

func (*SearchTemplate) IgnoreThrottled

func (r *SearchTemplate) IgnoreThrottled(ignorethrottled bool) *SearchTemplate

IgnoreThrottled If `true`, specified concrete, expanded, or aliased indices are not included in the response when throttled. API name: ignore_throttled

func (*SearchTemplate) IgnoreUnavailable

func (r *SearchTemplate) IgnoreUnavailable(ignoreunavailable bool) *SearchTemplate

IgnoreUnavailable If `false`, the request returns an error if it targets a missing or closed index. API name: ignore_unavailable

func (*SearchTemplate) Index

func (r *SearchTemplate) Index(index string) *SearchTemplate

Index Comma-separated list of data streams, indices, and aliases to search. Supports wildcards (*). API Name: index

func (*SearchTemplate) Params added in v8.9.0

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

Params Key-value pairs used to replace Mustache variables in the template. The key is the variable name. The value is the variable value. API name: params

func (SearchTemplate) Perform added in v8.7.0

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

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

func (*SearchTemplate) Preference

func (r *SearchTemplate) Preference(preference string) *SearchTemplate

Preference Specifies the node or shard the operation should be performed on. Random by default. API name: preference

func (*SearchTemplate) Profile

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

Profile If `true`, the query execution is profiled. API name: profile

func (*SearchTemplate) Raw

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

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

func (*SearchTemplate) Request

func (r *SearchTemplate) Request(req *Request) *SearchTemplate

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

func (*SearchTemplate) RestTotalHitsAsInt

func (r *SearchTemplate) RestTotalHitsAsInt(resttotalhitsasint bool) *SearchTemplate

RestTotalHitsAsInt If true, hits.total are rendered as an integer in the response. API name: rest_total_hits_as_int

func (*SearchTemplate) Routing

func (r *SearchTemplate) Routing(routing string) *SearchTemplate

Routing Custom value used to route operations to a specific shard. API name: routing

func (*SearchTemplate) Scroll

func (r *SearchTemplate) Scroll(duration string) *SearchTemplate

Scroll Specifies how long a consistent view of the index should be maintained for scrolled search. API name: scroll

func (*SearchTemplate) SearchType

func (r *SearchTemplate) SearchType(searchtype searchtype.SearchType) *SearchTemplate

SearchType The type of the search operation. API name: search_type

func (*SearchTemplate) Source added in v8.9.0

func (r *SearchTemplate) Source(source string) *SearchTemplate

Source An inline search template. Supports the same parameters as the search API's request body. Also supports Mustache variables. If no id is specified, this parameter is required. API name: source

func (*SearchTemplate) TypedKeys

func (r *SearchTemplate) TypedKeys(typedkeys bool) *SearchTemplate

TypedKeys If `true`, the response prefixes aggregation and suggester names with their respective types. API name: typed_keys

Jump to

Keyboard shortcuts

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