search

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2023 License: Apache-2.0 Imports: 15 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 map[string]types.RuntimeField `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/1ad7fe36297b3a8e187b2259dedaf68a47bc236e/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

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"`
}

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

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

API name: allow_no_indices

func (*Search) AllowPartialSearchResults

func (r *Search) AllowPartialSearchResults(b 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(b bool) *Search

API name: analyze_wildcard

func (*Search) Analyzer

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

API name: analyzer

func (*Search) BatchedReduceSize

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

API name: batched_reduce_size

func (*Search) CcsMinimizeRoundtrips

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

API name: ccs_minimize_roundtrips

func (*Search) DefaultOperator

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

API name: default_operator

func (*Search) Df

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

API name: df

func (Search) Do

func (r Search) Do(ctx 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(v string) *Search

API name: docvalue_fields

func (*Search) ExpandWildcards

func (r *Search) ExpandWildcards(v string) *Search

API name: expand_wildcards

func (*Search) Explain

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

API name: explain

func (*Search) From

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

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

API name: ignore_throttled

func (*Search) IgnoreUnavailable

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

API name: ignore_unavailable

func (*Search) Index

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

Index A single target to search. If the target is an index alias, it must resolve to a single index. API Name: index

func (*Search) Lenient

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

API name: lenient

func (*Search) MaxConcurrentShardRequests

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

API name: max_concurrent_shard_requests

func (*Search) MinCompatibleShardNode

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

API name: min_compatible_shard_node

func (Search) Perform

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

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

func (*Search) PreFilterShardSize

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

API name: pre_filter_shard_size

func (*Search) Preference

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

API name: preference

func (*Search) Q

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

API name: q

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

API name: request_cache

func (*Search) RestTotalHitsAsInt

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

API name: rest_total_hits_as_int

func (*Search) Routing

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

API name: routing

func (*Search) Scroll

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

API name: scroll

func (*Search) SearchType

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

API name: search_type

func (*Search) SeqNoPrimaryTerm

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

API name: seq_no_primary_term

func (*Search) Size

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

API name: size

func (*Search) Sort

func (r *Search) Sort(v string) *Search

API name: sort

func (*Search) SourceExcludes_

func (r *Search) SourceExcludes_(v string) *Search

API name: _source_excludes

func (*Search) SourceIncludes_

func (r *Search) SourceIncludes_(v string) *Search

API name: _source_includes

func (*Search) Source_

func (r *Search) Source_(v string) *Search

API name: _source

func (*Search) Stats

func (r *Search) Stats(v string) *Search

API name: stats

func (*Search) StoredFields

func (r *Search) StoredFields(v string) *Search

API name: stored_fields

func (*Search) SuggestField

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

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

func (*Search) SuggestMode

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

API name: suggest_mode

func (*Search) SuggestSize

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

API name: suggest_size

func (*Search) SuggestText

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

SuggestText The source text for which the suggestions should be returned. API name: suggest_text

func (*Search) TerminateAfter

func (r *Search) TerminateAfter(v string) *Search

API name: terminate_after

func (*Search) Timeout

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

API name: timeout

func (*Search) TrackScores

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

API name: track_scores

func (*Search) TrackTotalHits

func (r *Search) TrackTotalHits(v string) *Search

API name: track_total_hits

func (*Search) TypedKeys

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

API name: typed_keys

func (*Search) Version

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

API name: version

func (*Search) WaitForCheckpoints

func (r *Search) WaitForCheckpoints(v string) *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