search

package
v8.14.2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Search API where the search will only be executed after specified checkpoints are available due to a refresh. This API is designed for internal use by the fleet server project.

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(index string) *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 map[string]types.Aggregations `json:"aggregations,omitempty"`
	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. 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 *types.Highlight `json:"highlight,omitempty"`
	// IndicesBoost Boosts the _score of documents from specified indices.
	IndicesBoost []map[string]types.Float64 `json:"indices_boost,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 *types.Query                `json:"post_filter,omitempty"`
	Profile    *bool                       `json:"profile,omitempty"`
	// Query Defines the search definition using the Query DSL.
	Query   *types.Query    `json:"query,omitempty"`
	Rescore []types.Rescore `json:"rescore,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  []types.FieldValue           `json:"search_after,omitempty"`
	// SeqNoPrimaryTerm If true, returns sequence number and primary term of the last modification
	// of each hit. See Optimistic concurrency control.
	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 *types.SlicedScroll      `json:"slice,omitempty"`
	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      *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. Defaults to 0, which does not terminate query execution
	// 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.
	// Defaults to 10,000 hits.
	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/5fb8f1ce9c4605abcaa44aa0f17dbfc60497a757/specification/fleet/search/SearchRequest.ts#L55-L260

func NewRequest

func NewRequest() *Request

NewRequest returns a Request

func (*Request) FromJSON

func (r *Request) FromJSON(data string) (*Request, error)

FromJSON allows to load an arbitrary json into the request structure

func (*Request) UnmarshalJSON

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

type Response

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/5fb8f1ce9c4605abcaa44aa0f17dbfc60497a757/specification/fleet/search/SearchResponse.ts#L33-L50

func NewResponse

func NewResponse() *Response

NewResponse returns a Response

func (*Response) UnmarshalJSON

func (s *Response) UnmarshalJSON(data []byte) error
type Search struct {
	// contains filtered or unexported fields
}

func New

Search API where the search will only be executed after specified checkpoints are available due to a refresh. This API is designed for internal use by the fleet server project.

func (*Search) Aggregations

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

API name: aggregations

func (*Search) AllowNoIndices

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

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](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-replication.html#shard-failures). If false, returns an error with no partial results. Defaults to the configured cluster setting `search.default_allow_partial_results` which is true by default. API name: allow_partial_search_results

func (*Search) AnalyzeWildcard

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

API name: analyze_wildcard

func (*Search) Analyzer

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

API name: analyzer

func (*Search) BatchedReduceSize

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

API name: batched_reduce_size

func (*Search) CcsMinimizeRoundtrips

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

API name: ccs_minimize_roundtrips

func (*Search) Collapse

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

API name: collapse

func (*Search) DefaultOperator

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

API name: default_operator

func (*Search) Df

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

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) ExpandWildcards

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

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

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

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) From

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

From Starting document offset. 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

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

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) IgnoreThrottled

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

API name: ignore_throttled

func (*Search) IgnoreUnavailable

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

API name: ignore_unavailable

func (*Search) IndicesBoost

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) Lenient

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

API name: lenient

func (*Search) MaxConcurrentShardRequests

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

API name: max_concurrent_shard_requests

func (*Search) MinCompatibleShardNode

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

API name: min_compatible_shard_node

func (*Search) MinScore

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

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

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

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

API name: post_filter

func (*Search) PreFilterShardSize

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

API name: pre_filter_shard_size

func (*Search) Preference

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

API name: preference

func (*Search) Profile

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

API name: profile

func (*Search) Q

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

API name: q

func (*Search) Query

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

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

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

API name: request_cache

func (*Search) Rescore

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

API name: rescore

func (*Search) RestTotalHitsAsInt

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

API name: rest_total_hits_as_int

func (*Search) Routing

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

API name: routing

func (*Search) RuntimeMappings

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

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

API name: scroll

func (*Search) SearchAfter

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

API name: search_after

func (*Search) SearchType

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

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. See Optimistic concurrency control. 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

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

API name: slice

func (*Search) Sort

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

API name: sort

func (*Search) SourceExcludes_

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

API name: _source_excludes

func (*Search) SourceIncludes_

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

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

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

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

API name: suggest_mode

func (*Search) SuggestSize

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

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. 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. Defaults to 0, which does not terminate query execution 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. Defaults to 10,000 hits. API name: track_total_hits

func (*Search) TypedKeys

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

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

func (*Search) WaitForCheckpoints

func (r *Search) WaitForCheckpoints(waitforcheckpoints ...int64) *Search

WaitForCheckpoints A comma separated list of checkpoints. When configured, the search API will only be executed on a shard after the relevant checkpoint has become visible for search. Defaults to an empty list which will cause Elasticsearch to immediately execute the search. API name: wait_for_checkpoints

Jump to

Keyboard shortcuts

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