Documentation ¶
Overview ¶
Allows to use the Mustache language to pre-render a search definition.
Index ¶
- Variables
- type NewSearchTemplate
- type Request
- type Response
- type SearchTemplate
- func (r *SearchTemplate) AllowNoIndices(allownoindices bool) *SearchTemplate
- func (r *SearchTemplate) CcsMinimizeRoundtrips(ccsminimizeroundtrips bool) *SearchTemplate
- func (r SearchTemplate) Do(providedCtx context.Context) (*Response, error)
- func (r *SearchTemplate) ExpandWildcards(expandwildcards ...expandwildcard.ExpandWildcard) *SearchTemplate
- func (r *SearchTemplate) Explain(explain bool) *SearchTemplate
- func (r *SearchTemplate) Header(key, value string) *SearchTemplate
- func (r *SearchTemplate) HttpRequest(ctx context.Context) (*http.Request, error)
- func (r *SearchTemplate) Id(id string) *SearchTemplate
- func (r *SearchTemplate) IgnoreThrottled(ignorethrottled bool) *SearchTemplate
- func (r *SearchTemplate) IgnoreUnavailable(ignoreunavailable bool) *SearchTemplate
- func (r *SearchTemplate) Index(index string) *SearchTemplate
- func (r *SearchTemplate) Params(params map[string]json.RawMessage) *SearchTemplate
- func (r SearchTemplate) Perform(providedCtx context.Context) (*http.Response, error)
- func (r *SearchTemplate) Preference(preference string) *SearchTemplate
- func (r *SearchTemplate) Profile(profile bool) *SearchTemplate
- func (r *SearchTemplate) Raw(raw io.Reader) *SearchTemplate
- func (r *SearchTemplate) Request(req *Request) *SearchTemplate
- func (r *SearchTemplate) RestTotalHitsAsInt(resttotalhitsasint bool) *SearchTemplate
- func (r *SearchTemplate) Routing(routing string) *SearchTemplate
- func (r *SearchTemplate) Scroll(duration string) *SearchTemplate
- func (r *SearchTemplate) SearchType(searchtype searchtype.SearchType) *SearchTemplate
- func (r *SearchTemplate) Source(source string) *SearchTemplate
- func (r *SearchTemplate) TypedKeys(typedkeys bool) *SearchTemplate
Constants ¶
This section is empty.
Variables ¶
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
func (*Request) FromJSON ¶ added in v8.5.0
FromJSON allows to load an arbitrary json into the request structure
func (*Request) UnmarshalJSON ¶ added in v8.12.1
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
func (*Response) UnmarshalJSON ¶ added in v8.7.0
type SearchTemplate ¶
type SearchTemplate struct {
// contains filtered or unexported fields
}
func New ¶
func New(tp elastictransport.Interface) *SearchTemplate
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 ¶
HttpRequest returns the http.Request object built from the given parameters.
func (*SearchTemplate) Id ¶ added in v8.9.0
func (r *SearchTemplate) Id(id string) *SearchTemplate
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
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