Movatterモバイル変換


[0]ホーム

URL:


Notice  The highest tagged major version isv9.

search

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:16Imported by:100

Details

Repository

github.com/elastic/go-elasticsearch

Links

Documentation

Overview

Run a search.

Get search hits that match the query defined in the request.You can provide search queries using the `q` query string parameter or therequest body.If both are specified, only the query parameter is used.

If the Elasticsearch security features are enabled, you must have the readindex privilege for the target data stream, index, or alias. Forcross-cluster search, refer to the documentation about configuring CCSprivileges.To search a point in time (PIT) for an alias, you must have the `read` indexprivilege for the alias's data streams or indices.

**Search slicing**

When paging through a large number of documents, it can be helpful to splitthe search into multiple slices to consume them independently with the`slice` and `pit` properties.By default the splitting is done first on the shards, then locally on eachshard.The local splitting partitions the shard into contiguous ranges based onLucene document IDs.

For instance if the number of shards is equal to 2 and you request 4 slices,the slices 0 and 2 are assigned to the first shard and the slices 1 and 3 areassigned to the second shard.

IMPORTANT: The same point-in-time ID should be used for all slices.If different PIT IDs are used, slices can overlap and miss documents.This situation can occur because the splitting criterion is based on Lucenedocument IDs, which are not stable across changes to the index.

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

typeNewSearch

type NewSearch func() *Search

NewSearch type alias for index.

funcNewSearchFunc

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

typeRequest

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 An array of wildcard (`*`) field 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`, the request 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 An array of wildcard (`*`) field 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 The starting document offset, which must 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 Boost the `_score` of documents from specified indices.// The boost value is the factor by which scores are multiplied.// A boost value greater than `1.0` increases the score.// A boost value between `0` and `1.0` decreases the score.IndicesBoost []map[string]types.Float64 `json:"indices_boost,omitempty"`// Knn The approximate kNN search to run.Knn []types.KnnSearch `json:"knn,omitempty"`// MinScore The minimum `_score` for matching documents.// Documents with a lower `_score` are not included in search results and// results collected by aggregations.MinScore *types.Float64 `json:"min_score,omitempty"`// Pit Limit 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 The search definition using the Query DSL.Query *types.Query `json:"query,omitempty"`// Rank 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 One or more runtime fields in the search request.// These fields take precedence over mapped fields with the same name.RuntimeMappingstypes.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`, the request 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, which must not be 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` property.Size *int `json:"size,omitempty"`// Slice 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_ The source fields that are returned for matching documents.// These fields are returned in the `hits._source` property of the search// response.// If the `stored_fields` property is specified, the `_source` property defaults// to `false`.// Otherwise, it defaults to `true`.Source_types.SourceConfig `json:"_source,omitempty"`// Stats The 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 A comma-separated 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` property 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 The 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.//// IMPORTANT: Use with caution.// Elasticsearch applies this property to each shard handling the request.// When possible, let Elasticsearch perform early termination automatically.// Avoid specifying this property 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 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.TrackTotalHitstypes.TrackHits `json:"track_total_hits,omitempty"`// Version If `true`, the request returns the 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/470b4b9aaaa25cae633ec690e54b725c6fc939c7/specification/_global/search/SearchRequest.ts#L54-L590

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 {Aggregations map[string]types.Aggregate `json:"aggregations,omitempty"`Clusters_    *types.ClusterStatistics   `json:"_clusters,omitempty"`Fields       map[string]json.RawMessage `json:"fields,omitempty"`// Hits The returned documents and metadata.Hitstypes.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_ The identifier for the search and its search context.// You can use this scroll ID with the scroll API to retrieve the next batch of// search results for the request.// This property is returned only if the `scroll` query parameter is specified// in the request.ScrollId_ *string `json:"_scroll_id,omitempty"`// Shards_ A count of shards used for the request.Shards_types.ShardStatistics      `json:"_shards"`Suggest         map[string][]types.Suggest `json:"suggest,omitempty"`TerminatedEarly *bool                      `json:"terminated_early,omitempty"`// TimedOut If `true`, the request timed out before completion; returned results may be// partial or empty.TimedOutbool `json:"timed_out"`// Took The number of milliseconds it took Elasticsearch to run the request.// This value is calculated by measuring the time elapsed between receipt of a// request on the coordinating node and the time at which the coordinating node// is ready to send the response.// It includes://// * Communication time between the coordinating node and data nodes// * Time the request spends in the search thread pool, queued for execution// * Actual run time//// It does not include://// * Time needed to send the request to Elasticsearch// * Time needed to serialize the JSON response// * Time needed to send the response to a clientTookint64 `json:"took"`}

Response holds the response body struct for the package search

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

funcNewResponseadded inv8.7.0

func NewResponse() *Response

NewResponse returns a Response

func (*Response)UnmarshalJSONadded inv8.7.0

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

typeSearch

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

funcNew

Run a search.

Get search hits that match the query defined in the request.You can provide search queries using the `q` query string parameter or therequest body.If both are specified, only the query parameter is used.

If the Elasticsearch security features are enabled, you must have the readindex privilege for the target data stream, index, or alias. Forcross-cluster search, refer to the documentation about configuring CCSprivileges.To search a point in time (PIT) for an alias, you must have the `read` indexprivilege for the alias's data streams or indices.

**Search slicing**

When paging through a large number of documents, it can be helpful to splitthe search into multiple slices to consume them independently with the`slice` and `pit` properties.By default the splitting is done first on the shards, then locally on eachshard.The local splitting partitions the shard into contiguous ranges based onLucene document IDs.

For instance if the number of shards is equal to 2 and you request 4 slices,the slices 0 and 2 are assigned to the first shard and the slices 1 and 3 areassigned to the second shard.

IMPORTANT: The same point-in-time ID should be used for all slices.If different PIT IDs are used, slices can overlap and miss documents.This situation can occur because the splitting criterion is based on Lucenedocument IDs, which are not stable across changes to the index.

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

func (*Search)Aggregationsadded inv8.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(allownoindicesbool) *Search

AllowNoIndices If `false`, the request returns an error if any wildcard expression, indexalias, 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 indexstarts with `foo` but no index starts with `bar`.API name: allow_no_indices

func (*Search)AllowPartialSearchResults

func (r *Search) AllowPartialSearchResults(allowpartialsearchresultsbool) *Search

AllowPartialSearchResults If `true` and there are shard request timeouts or shard failures, the requestreturns partial results.If `false`, it returns an error with no partial results.

To override the default behavior, you can set the`search.default_allow_partial_results` cluster setting to `false`.API name: allow_partial_search_results

func (*Search)AnalyzeWildcard

func (r *Search) AnalyzeWildcard(analyzewildcardbool) *Search

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

func (*Search)Analyzer

func (r *Search) Analyzer(analyzerstring) *Search

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

func (*Search)BatchedReduceSize

func (r *Search) BatchedReduceSize(batchedreducesizestring) *Search

BatchedReduceSize The number of shard results that should be reduced at once on thecoordinating node.If the potential number of shards in the request can be large, this valueshould be used as a protection mechanism to reduce the memory overhead persearch request.API name: batched_reduce_size

func (*Search)CcsMinimizeRoundtrips

func (r *Search) CcsMinimizeRoundtrips(ccsminimizeroundtripsbool) *Search

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

func (*Search)Collapseadded inv8.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(defaultoperatoroperator.Operator) *Search

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

func (*Search)Df

func (r *Search) Df(dfstring) *Search

Df The field to use as a default when no field prefix is given in the querystring.This parameter can be used only when the `q` query string parameter isspecified.API name: df

func (Search)Do

func (rSearch) Do(providedCtxcontext.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 An array of wildcard (`*`) field 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)ErrorTraceadded inv8.14.0

func (r *Search) ErrorTrace(errortracebool) *Search

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

func (*Search)ExpandWildcards

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

ExpandWildcards The type of index that wildcard patterns can match.If the request can target data streams, this argument determines whetherwildcard expressions match hidden data streams.It supports comma-separated values such as `open,hidden`.API name: expand_wildcards

func (*Search)Explain

func (r *Search) Explain(explainbool) *Search

Explain If `true`, the request returns detailed information about score computationas part of a hit.API name: explain

func (*Search)Extadded inv8.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)Fieldsadded inv8.9.0

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

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

func (*Search)FilterPathadded inv8.14.0

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

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

func (*Search)ForceSyntheticSourceadded inv8.13.1

func (r *Search) ForceSyntheticSource(forcesyntheticsourcebool) *Search

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

func (*Search)From

func (r *Search) From(fromint) *Search

From The starting document offset, which must 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, valuestring) *Search

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

func (*Search)Highlightadded inv8.9.0

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

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

func (*Search)HttpRequest

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

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

func (*Search)Humanadded inv8.14.0

func (r *Search) Human(humanbool) *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 humanreadable values will be omitted. This makes sense for responses beingconsumedonly by machines.API name: human

func (*Search)IgnoreThrottled

func (r *Search) IgnoreThrottled(ignorethrottledbool) *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(ignoreunavailablebool) *Search

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

func (*Search)IncludeNamedQueriesScoreadded inv8.15.0

func (r *Search) IncludeNamedQueriesScore(includenamedqueriesscorebool) *Search

IncludeNamedQueriesScore If `true`, the response includes the score contribution from any namedqueries.

This functionality reruns each named query on every hit in a search response.Typically, this adds a small overhead to a request.However, using computationally expensive named queries on a large number ofhits may add significant overhead.API name: include_named_queries_score

func (*Search)Index

func (r *Search) Index(indexstring) *Search

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

func (*Search)IndicesBoostadded inv8.9.0

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

IndicesBoost Boost the `_score` of documents from specified indices.The boost value is the factor by which scores are multiplied.A boost value greater than `1.0` increases the score.A boost value between `0` and `1.0` decreases the score.API name: indices_boost

func (*Search)Knnadded inv8.9.0

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

Knn The approximate kNN search to run.API name: knn

func (*Search)Lenient

func (r *Search) Lenient(lenientbool) *Search

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

func (*Search)MaxConcurrentShardRequests

func (r *Search) MaxConcurrentShardRequests(maxconcurrentshardrequestsstring) *Search

MaxConcurrentShardRequests The number of concurrent shard requests per node that the search runsconcurrently.This value should be used to limit the impact of the search on the cluster inorder to limit the number of concurrent shard requests.API name: max_concurrent_shard_requests

func (*Search)MinCompatibleShardNode

func (r *Search) MinCompatibleShardNode(versionstringstring) *Search

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

func (*Search)MinScoreadded inv8.9.0

func (r *Search) MinScore(minscoretypes.Float64) *Search

MinScore The minimum `_score` for matching documents.Documents with a lower `_score` are not included in search results andresults collected by aggregations.API name: min_score

func (Search)Performadded inv8.7.0

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

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

func (*Search)Pitadded inv8.9.0

Pit Limit 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)PostFilteradded inv8.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(prefiltershardsizestring) *Search

PreFilterShardSize A threshold that enforces a pre-filter roundtrip to prefilter search shardsbased on query rewriting if the number of shards the search request expandsto exceeds the threshold.This filter roundtrip can limit the number of shards significantly if forinstance a shard can not match any documents based on its rewrite method (ifdate filters are mandatory to match but the shard bounds and the query aredisjoint).When unspecified, the pre-filter phase is executed if any of these conditionsis 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(preferencestring) *Search

Preference The nodes and shards used for the search.By default, Elasticsearch selects from eligible nodes and shards usingadaptive 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 ifnot, select shards using the default method;* `_only_nodes:<node-id>,<node-id>` to run the search on only the specifiednodes 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 thespecified nodes are available, select shards from any available node usingthe default method;* `_prefer_nodes:<node-id>,<node-id>` to if possible, run the search on thespecified 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 routesearches with the same `<custom-string>` to the same shards in the sameorder.API name: preference

func (*Search)Prettyadded inv8.14.0

func (r *Search) Pretty(prettybool) *Search

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

func (*Search)Profileadded inv8.9.0

func (r *Search) Profile(profilebool) *Search

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

func (*Search)Q

func (r *Search) Q(qstring) *Search

Q A query in the Lucene query string syntax.Query parameter searches do not support the full Elasticsearch Query DSL butare handy for testing.

IMPORTANT: This parameter overrides the query parameter in the request body.If both parameters are specified, documents matching the query request bodyparameter are not returned.API name: q

func (*Search)Queryadded inv8.9.0

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

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

func (*Search)Rankadded inv8.9.0

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

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

func (*Search)Raw

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

Raw takes a json payload as input which is then passed to the http.RequestIf 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(requestcachebool) *Search

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

func (*Search)Rescoreadded inv8.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(resttotalhitsasintbool) *Search

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

func (*Search)Retrieveradded inv8.14.0

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

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

func (*Search)Routing

func (r *Search) Routing(routingstring) *Search

Routing A custom value that is used to route operations to a specific shard.API name: routing

func (*Search)RuntimeMappingsadded inv8.9.0

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

RuntimeMappings 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)ScriptFieldsadded inv8.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(durationstring) *Search

Scroll The period to retain the search context for scrolling.By default, this value cannot exceed `1d` (24 hours).You can change this limit by using the `search.max_keep_alive` cluster-levelsetting.API name: scroll

func (*Search)SearchAfteradded inv8.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 theprevious page.API name: search_after

func (*Search)SearchType

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

SearchType Indicates how distributed term frequencies are calculated for relevancescoring.API name: search_type

func (*Search)SeqNoPrimaryTerm

func (r *Search) SeqNoPrimaryTerm(seqnoprimarytermbool) *Search

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

func (*Search)Size

func (r *Search) Size(sizeint) *Search

Size The number of hits to return, which must not be 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` property.API name: size

func (*Search)Sliceadded inv8.9.0

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

Slice Split a scrolled search into multiple slices that can be consumedindependently.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 specifiedin `_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` queryparameter.If the `_source` parameter is `false`, this parameter is ignored.API name: _source_includes

func (*Search)Source_

func (r *Search) Source_(sourceconfigtypes.SourceConfig) *Search

Source_ The source fields that are returned for matching documents.These fields are returned in the `hits._source` property of the searchresponse.If the `stored_fields` property is specified, the `_source` property defaultsto `false`.Otherwise, it defaults to `true`.API name: _source

func (*Search)Stats

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

Stats The 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 A comma-separated 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` property defaults to `false`.You can pass `_source: true` to return both source fields and stored fieldsin the search response.API name: stored_fields

func (*Search)Suggestadded inv8.9.0

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

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

func (*Search)SuggestField

func (r *Search) SuggestField(fieldstring) *Search

SuggestField The field to use for suggestions.API name: suggest_field

func (*Search)SuggestMode

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

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

func (*Search)SuggestSize

func (r *Search) SuggestSize(suggestsizestring) *Search

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

func (*Search)SuggestText

func (r *Search) SuggestText(suggesttextstring) *Search

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

func (*Search)TerminateAfter

func (r *Search) TerminateAfter(terminateafterint64) *Search

TerminateAfter The 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.

IMPORTANT: Use with caution.Elasticsearch applies this property to each shard handling the request.When possible, let Elasticsearch perform early termination automatically.Avoid specifying this property for requests that target data streams withbacking 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(timeoutstring) *Search

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

func (*Search)TrackScores

func (r *Search) TrackScores(trackscoresbool) *Search

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

func (*Search)TrackTotalHits

func (r *Search) TrackTotalHits(trackhitstypes.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 someperformance.If `false`, the response does not include the total number of hits matchingthe query.API name: track_total_hits

func (*Search)TypedKeys

func (r *Search) TypedKeys(typedkeysbool) *Search

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

func (*Search)Version

func (r *Search) Version(versionbool) *Search

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

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