search

package
v8.14.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: Apache-2.0 Imports: 16 Imported by: 61

Documentation

Overview

Returns results matching a query.

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 NewSearch

type NewSearch func() *Search

NewSearch type alias for index.

func NewSearchFunc

func NewSearchFunc(tp elastictransport.Interface) NewSearch

NewSearchFunc returns a new instance of Search 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 {

	// Aggregations Defines the aggregations that are run as part of the search request.
	Aggregations map[string]types.Aggregations `json:"aggregations,omitempty"`
	// Collapse Collapses search results the values of the specified field.
	Collapse *types.FieldCollapse `json:"collapse,omitempty"`
	// DocvalueFields Array of wildcard (`*`) patterns.
	// The request returns doc values for field names matching these patterns in the
	// `hits.fields` property of the response.
	DocvalueFields []types.FieldAndFormat `json:"docvalue_fields,omitempty"`
	// Explain If true, returns detailed information about score computation as part of a
	// hit.
	Explain *bool `json:"explain,omitempty"`
	// Ext Configuration of search extensions defined by Elasticsearch plugins.
	Ext map[string]json.RawMessage `json:"ext,omitempty"`
	// Fields Array of wildcard (`*`) patterns.
	// The request returns values for field names matching these patterns in the
	// `hits.fields` property of the response.
	Fields []types.FieldAndFormat `json:"fields,omitempty"`
	// From Starting document offset.
	// Needs to be non-negative.
	// By default, you cannot page through more than 10,000 hits using the `from`
	// and `size` parameters.
	// To page through more hits, use the `search_after` parameter.
	From *int `json:"from,omitempty"`
	// Highlight Specifies the highlighter to use for retrieving highlighted snippets from one
	// or more fields in your search results.
	Highlight *types.Highlight `json:"highlight,omitempty"`
	// IndicesBoost Boosts the _score of documents from specified indices.
	IndicesBoost []map[string]types.Float64 `json:"indices_boost,omitempty"`
	// Knn Defines the approximate kNN search to run.
	Knn []types.KnnSearch `json:"knn,omitempty"`
	// MinScore Minimum `_score` for matching documents.
	// Documents with a lower `_score` are not included in the search results.
	MinScore *types.Float64 `json:"min_score,omitempty"`
	// Pit Limits the search to a point in time (PIT).
	// If you provide a PIT, you cannot specify an `<index>` in the request path.
	Pit *types.PointInTimeReference `json:"pit,omitempty"`
	// PostFilter Use the `post_filter` parameter to filter search results.
	// The search hits are filtered after the aggregations are calculated.
	// A post filter has no impact on the aggregation results.
	PostFilter *types.Query `json:"post_filter,omitempty"`
	// Profile Set to `true` to return detailed timing information about the execution of
	// individual components in a search request.
	// NOTE: This is a debugging tool and adds significant overhead to search
	// execution.
	Profile *bool `json:"profile,omitempty"`
	// Query Defines the search definition using the Query DSL.
	Query *types.Query `json:"query,omitempty"`
	// Rank Defines the Reciprocal Rank Fusion (RRF) to use.
	Rank *types.RankContainer `json:"rank,omitempty"`
	// Rescore Can be used to improve precision by reordering just the top (for example 100
	// - 500) documents returned by the `query` and `post_filter` phases.
	Rescore []types.Rescore `json:"rescore,omitempty"`
	// Retriever A retriever is a specification to describe top documents returned from a
	// search. A retriever replaces other elements of the search API that also
	// return top documents such as query and knn.
	Retriever *types.RetrieverContainer `json:"retriever,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"`
	// ScriptFields Retrieve a script evaluation (based on different fields) for each hit.
	ScriptFields map[string]types.ScriptField `json:"script_fields,omitempty"`
	// SearchAfter Used to retrieve the next page of hits using a set of sort values from the
	// previous page.
	SearchAfter []types.FieldValue `json:"search_after,omitempty"`
	// SeqNoPrimaryTerm If `true`, returns sequence number and primary term of the last modification
	// of each hit.
	SeqNoPrimaryTerm *bool `json:"seq_no_primary_term,omitempty"`
	// Size The number of hits to return.
	// By default, you cannot page through more than 10,000 hits using the `from`
	// and `size` parameters.
	// To page through more hits, use the `search_after` parameter.
	Size *int `json:"size,omitempty"`
	// Slice Can be used to split a scrolled search into multiple slices that can be
	// consumed independently.
	Slice *types.SlicedScroll `json:"slice,omitempty"`
	// Sort A comma-separated list of <field>:<direction> pairs.
	Sort []types.SortCombinations `json:"sort,omitempty"`
	// Source_ Indicates which source fields are returned for matching documents.
	// These fields are returned in the hits._source property of the search
	// response.
	Source_ types.SourceConfig `json:"_source,omitempty"`
	// Stats Stats groups to associate with the search.
	// Each group maintains a statistics aggregation for its associated searches.
	// You can retrieve these stats using the indices stats API.
	Stats []string `json:"stats,omitempty"`
	// StoredFields List of stored fields to return as part of a hit.
	// If no fields are specified, no stored fields are included in the response.
	// If this field is specified, the `_source` parameter defaults to `false`.
	// You can pass `_source: true` to return both source fields and stored fields
	// in the search response.
	StoredFields []string `json:"stored_fields,omitempty"`
	// Suggest Defines a suggester that provides similar looking terms based on a provided
	// text.
	Suggest *types.Suggester `json:"suggest,omitempty"`
	// TerminateAfter Maximum number of documents to collect for each shard.
	// If a query reaches this limit, Elasticsearch terminates the query early.
	// Elasticsearch collects documents before sorting.
	// Use with caution.
	// Elasticsearch applies this parameter to each shard handling the request.
	// When possible, let Elasticsearch perform early termination automatically.
	// Avoid specifying this parameter for requests that target data streams with
	// backing indices across multiple data tiers.
	// If set to `0` (default), the query does not terminate early.
	TerminateAfter *int64 `json:"terminate_after,omitempty"`
	// Timeout Specifies the period of time to wait for a response from each shard.
	// If no response is received before the timeout expires, the request fails and
	// returns an error.
	// Defaults to no timeout.
	Timeout *string `json:"timeout,omitempty"`
	// TrackScores If true, calculate and return document scores, even if the scores are not
	// used for sorting.
	TrackScores *bool `json:"track_scores,omitempty"`
	// TrackTotalHits Number of hits matching the query to count accurately.
	// If `true`, the exact number of hits is returned at the cost of some
	// performance.
	// If `false`, the  response does not include the total number of hits matching
	// the query.
	TrackTotalHits types.TrackHits `json:"track_total_hits,omitempty"`
	// Version If true, returns document version as part of a hit.
	Version *bool `json:"version,omitempty"`
}

Request holds the request body struct for the package search

https://github.com/elastic/elasticsearch-specification/blob/07bf82537a186562d8699685e3704ea338b268ef/specification/_global/search/SearchRequest.ts#L54-L520

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 search

https://github.com/elastic/elasticsearch-specification/blob/07bf82537a186562d8699685e3704ea338b268ef/specification/_global/search/SearchResponse.ts#L34-L36

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 Search struct {
	// contains filtered or unexported fields
}

func (*Search) Aggregations added in v8.9.0

func (r *Search) Aggregations(aggregations map[string]types.Aggregations) *Search

Aggregations Defines the aggregations that are run as part of the search request. API name: aggregations

func (*Search) AllowNoIndices

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

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 (*Search) AllowPartialSearchResults

func (r *Search) AllowPartialSearchResults(allowpartialsearchresults bool) *Search

AllowPartialSearchResults If true, returns partial results if there are shard request timeouts or shard failures. If false, returns an error with no partial results. API name: allow_partial_search_results

func (*Search) AnalyzeWildcard

func (r *Search) AnalyzeWildcard(analyzewildcard bool) *Search

AnalyzeWildcard If true, wildcard and prefix queries are analyzed. This parameter can only be used when the q query string parameter is specified. API name: analyze_wildcard

func (*Search) Analyzer

func (r *Search) Analyzer(analyzer string) *Search

Analyzer Analyzer to use for the query string. This parameter can only be used when the q query string parameter is specified. API name: analyzer

func (*Search) BatchedReduceSize

func (r *Search) BatchedReduceSize(batchedreducesize string) *Search

BatchedReduceSize The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. API name: batched_reduce_size

func (*Search) CcsMinimizeRoundtrips

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

CcsMinimizeRoundtrips If true, network round-trips between the coordinating node and the remote clusters are minimized when executing cross-cluster search (CCS) requests. API name: ccs_minimize_roundtrips

func (*Search) Collapse added in v8.9.0

func (r *Search) Collapse(collapse *types.FieldCollapse) *Search

Collapse Collapses search results the values of the specified field. API name: collapse

func (*Search) DefaultOperator

func (r *Search) DefaultOperator(defaultoperator operator.Operator) *Search

DefaultOperator The default operator for query string query: AND or OR. This parameter can only be used when the `q` query string parameter is specified. API name: default_operator

func (*Search) Df

func (r *Search) Df(df string) *Search

Df Field to use as default where no field prefix is given in the query string. This parameter can only be used when the q query string parameter is specified. API name: df

func (Search) Do

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

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

func (*Search) DocvalueFields

func (r *Search) DocvalueFields(docvaluefields ...types.FieldAndFormat) *Search

DocvalueFields Array of wildcard (`*`) patterns. The request returns doc values for field names matching these patterns in the `hits.fields` property of the response. API name: docvalue_fields

func (*Search) ErrorTrace added in v8.14.0

func (r *Search) ErrorTrace(errortrace bool) *Search

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

func (*Search) ExpandWildcards

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

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`. API name: expand_wildcards

func (*Search) Explain

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

Explain If true, returns detailed information about score computation as part of a hit. API name: explain

func (*Search) Ext added in v8.9.0

func (r *Search) Ext(ext map[string]json.RawMessage) *Search

Ext Configuration of search extensions defined by Elasticsearch plugins. API name: ext

func (*Search) Fields added in v8.9.0

func (r *Search) Fields(fields ...types.FieldAndFormat) *Search

Fields Array of wildcard (`*`) patterns. The request returns values for field names matching these patterns in the `hits.fields` property of the response. API name: fields

func (*Search) FilterPath added in v8.14.0

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

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

func (*Search) ForceSyntheticSource added in v8.13.1

func (r *Search) ForceSyntheticSource(forcesyntheticsource bool) *Search

ForceSyntheticSource Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index. API name: force_synthetic_source

func (*Search) From

func (r *Search) From(from int) *Search

From Starting document offset. Needs to be non-negative. By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters. To page through more hits, use the `search_after` parameter. API name: from

func (*Search) Header

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

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

func (*Search) Highlight added in v8.9.0

func (r *Search) Highlight(highlight *types.Highlight) *Search

Highlight Specifies the highlighter to use for retrieving highlighted snippets from one or more fields in your search results. API name: highlight

func (*Search) HttpRequest

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

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

func (*Search) Human added in v8.14.0

func (r *Search) Human(human bool) *Search

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

func (*Search) IgnoreThrottled

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

IgnoreThrottled If `true`, concrete, expanded or aliased indices will be ignored when frozen. API name: ignore_throttled

func (*Search) IgnoreUnavailable

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

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

func (*Search) Index

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

Index Comma-separated list of data streams, indices, and aliases to search. Supports wildcards (`*`). To search all data streams and indices, omit this parameter or use `*` or `_all`. API Name: index

func (*Search) IndicesBoost added in v8.9.0

func (r *Search) IndicesBoost(indicesboosts ...map[string]types.Float64) *Search

IndicesBoost Boosts the _score of documents from specified indices. API name: indices_boost

func (*Search) Knn added in v8.9.0

func (r *Search) Knn(knns ...types.KnnSearch) *Search

Knn Defines the approximate kNN search to run. API name: knn

func (*Search) Lenient

func (r *Search) Lenient(lenient bool) *Search

Lenient If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored. This parameter can only be used when the `q` query string parameter is specified. API name: lenient

func (*Search) MaxConcurrentShardRequests

func (r *Search) MaxConcurrentShardRequests(maxconcurrentshardrequests string) *Search

MaxConcurrentShardRequests Defines the number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests. API name: max_concurrent_shard_requests

func (*Search) MinCompatibleShardNode

func (r *Search) MinCompatibleShardNode(versionstring string) *Search

MinCompatibleShardNode The minimum version of the node that can handle the request Any handling node with a lower version will fail the request. API name: min_compatible_shard_node

func (*Search) MinScore added in v8.9.0

func (r *Search) MinScore(minscore types.Float64) *Search

MinScore Minimum `_score` for matching documents. Documents with a lower `_score` are not included in the search results. API name: min_score

func (Search) Perform added in v8.7.0

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

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

func (*Search) Pit added in v8.9.0

func (r *Search) Pit(pit *types.PointInTimeReference) *Search

Pit Limits the search to a point in time (PIT). If you provide a PIT, you cannot specify an `<index>` in the request path. API name: pit

func (*Search) PostFilter added in v8.9.0

func (r *Search) PostFilter(postfilter *types.Query) *Search

PostFilter Use the `post_filter` parameter to filter search results. The search hits are filtered after the aggregations are calculated. A post filter has no impact on the aggregation results. API name: post_filter

func (*Search) PreFilterShardSize

func (r *Search) PreFilterShardSize(prefiltershardsize string) *Search

PreFilterShardSize Defines a threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method (if date filters are mandatory to match but the shard bounds and the query are disjoint). When unspecified, the pre-filter phase is executed if any of these conditions is met: the request targets more than 128 shards; the request targets one or more read-only index; the primary sort of the query targets an indexed field. API name: pre_filter_shard_size

func (*Search) Preference

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

Preference Nodes and shards used for the search. By default, Elasticsearch selects from eligible nodes and shards using adaptive replica selection, accounting for allocation awareness. Valid values are: `_only_local` to run the search only on shards on the local node; `_local` to, if possible, run the search on shards on the local node, or if not, select shards using the default method; `_only_nodes:<node-id>,<node-id>` to run the search on only the specified nodes IDs, where, if suitable shards exist on more than one selected node, use shards on those nodes using the default method, or if none of the specified nodes are available, select shards from any available node using the default method; `_prefer_nodes:<node-id>,<node-id>` to if possible, run the search on the specified nodes IDs, or if not, select shards using the default method; `_shards:<shard>,<shard>` to run the search only on the specified shards; `<custom-string>` (any string that does not start with `_`) to route searches with the same `<custom-string>` to the same shards in the same order. API name: preference

func (*Search) Pretty added in v8.14.0

func (r *Search) Pretty(pretty bool) *Search

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

func (*Search) Profile added in v8.9.0

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

Profile Set to `true` to return detailed timing information about the execution of individual components in a search request. NOTE: This is a debugging tool and adds significant overhead to search execution. API name: profile

func (*Search) Q

func (r *Search) Q(q string) *Search

Q Query in the Lucene query string syntax using query parameter search. Query parameter searches do not support the full Elasticsearch Query DSL but are handy for testing. API name: q

func (*Search) Query added in v8.9.0

func (r *Search) Query(query *types.Query) *Search

Query Defines the search definition using the Query DSL. API name: query

func (*Search) Rank added in v8.9.0

func (r *Search) Rank(rank *types.RankContainer) *Search

Rank Defines the Reciprocal Rank Fusion (RRF) to use. API name: rank

func (*Search) Raw

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

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

func (*Search) Request

func (r *Search) Request(req *Request) *Search

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

func (*Search) RequestCache

func (r *Search) RequestCache(requestcache bool) *Search

RequestCache If `true`, the caching of search results is enabled for requests where `size` is `0`. Defaults to index level settings. API name: request_cache

func (*Search) Rescore added in v8.9.0

func (r *Search) Rescore(rescores ...types.Rescore) *Search

Rescore Can be used to improve precision by reordering just the top (for example 100 - 500) documents returned by the `query` and `post_filter` phases. API name: rescore

func (*Search) RestTotalHitsAsInt

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

RestTotalHitsAsInt Indicates whether `hits.total` should be rendered as an integer or an object in the rest search response. API name: rest_total_hits_as_int

func (*Search) Retriever added in v8.14.0

func (r *Search) Retriever(retriever *types.RetrieverContainer) *Search

Retriever A retriever is a specification to describe top documents returned from a search. A retriever replaces other elements of the search API that also return top documents such as query and knn. API name: retriever

func (*Search) Routing

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

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

func (*Search) RuntimeMappings added in v8.9.0

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

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 (*Search) ScriptFields added in v8.9.0

func (r *Search) ScriptFields(scriptfields map[string]types.ScriptField) *Search

ScriptFields Retrieve a script evaluation (based on different fields) for each hit. API name: script_fields

func (*Search) Scroll

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

Scroll Period to retain the search context for scrolling. See Scroll search results. By default, this value cannot exceed `1d` (24 hours). You can change this limit using the `search.max_keep_alive` cluster-level setting. API name: scroll

func (*Search) SearchAfter added in v8.9.0

func (r *Search) SearchAfter(sortresults ...types.FieldValue) *Search

SearchAfter Used to retrieve the next page of hits using a set of sort values from the previous page. API name: search_after

func (*Search) SearchType

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

SearchType How distributed term frequencies are calculated for relevance scoring. API name: search_type

func (*Search) SeqNoPrimaryTerm

func (r *Search) SeqNoPrimaryTerm(seqnoprimaryterm bool) *Search

SeqNoPrimaryTerm If `true`, returns sequence number and primary term of the last modification of each hit. API name: seq_no_primary_term

func (*Search) Size

func (r *Search) Size(size int) *Search

Size The number of hits to return. By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters. To page through more hits, use the `search_after` parameter. API name: size

func (*Search) Slice added in v8.9.0

func (r *Search) Slice(slice *types.SlicedScroll) *Search

Slice Can be used to split a scrolled search into multiple slices that can be consumed independently. API name: slice

func (*Search) Sort

func (r *Search) Sort(sorts ...types.SortCombinations) *Search

Sort A comma-separated list of <field>:<direction> pairs. API name: sort

func (*Search) SourceExcludes_

func (r *Search) SourceExcludes_(fields ...string) *Search

SourceExcludes_ A comma-separated list of source fields to exclude from the response. You can also use this parameter to exclude fields from the subset specified in `_source_includes` query parameter. If the `_source` parameter is `false`, this parameter is ignored. API name: _source_excludes

func (*Search) SourceIncludes_

func (r *Search) SourceIncludes_(fields ...string) *Search

SourceIncludes_ A comma-separated list of source fields to include in the response. If this parameter is specified, only these source fields are returned. You can exclude fields from this subset using the `_source_excludes` query parameter. If the `_source` parameter is `false`, this parameter is ignored. API name: _source_includes

func (*Search) Source_

func (r *Search) Source_(sourceconfig types.SourceConfig) *Search

Source_ Indicates which source fields are returned for matching documents. These fields are returned in the hits._source property of the search response. API name: _source

func (*Search) Stats

func (r *Search) Stats(stats ...string) *Search

Stats Stats groups to associate with the search. Each group maintains a statistics aggregation for its associated searches. You can retrieve these stats using the indices stats API. API name: stats

func (*Search) StoredFields

func (r *Search) StoredFields(fields ...string) *Search

StoredFields List of stored fields to return as part of a hit. If no fields are specified, no stored fields are included in the response. If this field is specified, the `_source` parameter defaults to `false`. You can pass `_source: true` to return both source fields and stored fields in the search response. API name: stored_fields

func (*Search) Suggest added in v8.9.0

func (r *Search) Suggest(suggest *types.Suggester) *Search

Suggest Defines a suggester that provides similar looking terms based on a provided text. API name: suggest

func (*Search) SuggestField

func (r *Search) SuggestField(field string) *Search

SuggestField Specifies which field to use for suggestions. API name: suggest_field

func (*Search) SuggestMode

func (r *Search) SuggestMode(suggestmode suggestmode.SuggestMode) *Search

SuggestMode Specifies the suggest mode. This parameter can only be used when the `suggest_field` and `suggest_text` query string parameters are specified. API name: suggest_mode

func (*Search) SuggestSize

func (r *Search) SuggestSize(suggestsize string) *Search

SuggestSize Number of suggestions to return. This parameter can only be used when the `suggest_field` and `suggest_text` query string parameters are specified. API name: suggest_size

func (*Search) SuggestText

func (r *Search) SuggestText(suggesttext string) *Search

SuggestText The source text for which the suggestions should be returned. This parameter can only be used when the `suggest_field` and `suggest_text` query string parameters are specified. API name: suggest_text

func (*Search) TerminateAfter

func (r *Search) TerminateAfter(terminateafter int64) *Search

TerminateAfter Maximum number of documents to collect for each shard. If a query reaches this limit, Elasticsearch terminates the query early. Elasticsearch collects documents before sorting. Use with caution. Elasticsearch applies this parameter to each shard handling the request. When possible, let Elasticsearch perform early termination automatically. Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers. If set to `0` (default), the query does not terminate early. API name: terminate_after

func (*Search) Timeout

func (r *Search) Timeout(timeout string) *Search

Timeout Specifies the period of time to wait for a response from each shard. If no response is received before the timeout expires, the request fails and returns an error. Defaults to no timeout. API name: timeout

func (*Search) TrackScores

func (r *Search) TrackScores(trackscores bool) *Search

TrackScores If true, calculate and return document scores, even if the scores are not used for sorting. API name: track_scores

func (*Search) TrackTotalHits

func (r *Search) TrackTotalHits(trackhits types.TrackHits) *Search

TrackTotalHits Number of hits matching the query to count accurately. If `true`, the exact number of hits is returned at the cost of some performance. If `false`, the response does not include the total number of hits matching the query. API name: track_total_hits

func (*Search) TypedKeys

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

TypedKeys If `true`, aggregation and suggester names are be prefixed by their respective types in the response. API name: typed_keys

func (*Search) Version

func (r *Search) Version(version bool) *Search

Version If true, returns document version as part of a hit. API name: version

Jump to

Keyboard shortcuts

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