Documentation
¶
Overview ¶
Run multiple searches.
The format of the request is similar to the bulk API format and makes use of the newline delimited JSON (NDJSON) format. The structure is as follows:
``` header\n body\n header\n body\n ```
This structure is specifically optimized to reduce parsing if a specific search ends up redirected to another node.
IMPORTANT: The final line of data must end with a newline character `\n`. Each newline character may be preceded by a carriage return `\r`. When sending requests to this endpoint the `Content-Type` header should be set to `application/x-ndjson`.
Index ¶
- Variables
- type Msearch
- func (r *Msearch) AddSearch(header types.MultisearchHeader, body types.MultisearchBody) error
- func (r *Msearch) AllowNoIndices(allownoindices bool) *Msearch
- func (r *Msearch) CcsMinimizeRoundtrips(ccsminimizeroundtrips bool) *Msearch
- func (r Msearch) Do(providedCtx context.Context) (*Response, error)
- func (r *Msearch) ErrorTrace(errortrace bool) *Msearch
- func (r *Msearch) ExpandWildcards(expandwildcards ...expandwildcard.ExpandWildcard) *Msearch
- func (r *Msearch) FilterPath(filterpaths ...string) *Msearch
- func (r *Msearch) Header(key, value string) *Msearch
- func (r *Msearch) HttpRequest(ctx context.Context) (*http.Request, error)
- func (r *Msearch) Human(human bool) *Msearch
- func (r *Msearch) IgnoreThrottled(ignorethrottled bool) *Msearch
- func (r *Msearch) IgnoreUnavailable(ignoreunavailable bool) *Msearch
- func (r *Msearch) IncludeNamedQueriesScore(includenamedqueriesscore bool) *Msearch
- func (r *Msearch) Index(index string) *Msearch
- func (r *Msearch) MaxConcurrentSearches(maxconcurrentsearches string) *Msearch
- func (r *Msearch) MaxConcurrentShardRequests(maxconcurrentshardrequests string) *Msearch
- func (r Msearch) Perform(providedCtx context.Context) (*http.Response, error)
- func (r *Msearch) PreFilterShardSize(prefiltershardsize string) *Msearch
- func (r *Msearch) Pretty(pretty bool) *Msearch
- func (r *Msearch) Raw(raw io.Reader) *Msearch
- func (r *Msearch) Request(req *Request) *Msearch
- func (r *Msearch) RestTotalHitsAsInt(resttotalhitsasint bool) *Msearch
- func (r *Msearch) Routing(routing string) *Msearch
- func (r *Msearch) SearchType(searchtype searchtype.SearchType) *Msearch
- func (r *Msearch) TypedKeys(typedkeys bool) *Msearch
- type NewMsearch
- type Request
- type Response
Constants ¶
This section is empty.
Variables ¶
var ErrBuildPath = errors.New("cannot build path, check for missing path parameters")
ErrBuildPath is returned in case of missing parameters within the build of the request.
Functions ¶
This section is empty.
Types ¶
type Msearch ¶
type Msearch struct {
// contains filtered or unexported fields
}
func New ¶
func New(tp elastictransport.Interface) *Msearch
Run multiple searches.
The format of the request is similar to the bulk API format and makes use of the newline delimited JSON (NDJSON) format. The structure is as follows:
``` header\n body\n header\n body\n ```
This structure is specifically optimized to reduce parsing if a specific search ends up redirected to another node.
IMPORTANT: The final line of data must end with a newline character `\n`. Each newline character may be preceded by a carriage return `\r`. When sending requests to this endpoint the `Content-Type` header should be set to `application/x-ndjson`.
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html
func (*Msearch) AddSearch ¶ added in v8.10.0
func (r *Msearch) AddSearch(header types.MultisearchHeader, body types.MultisearchBody) error
AddSearch is a helper function to add a new search to the buffer of the current msearch request.
func (*Msearch) AllowNoIndices ¶
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 (*Msearch) CcsMinimizeRoundtrips ¶
CcsMinimizeRoundtrips If true, network roundtrips between the coordinating node and remote clusters are minimized for cross-cluster search requests. API name: ccs_minimize_roundtrips
func (Msearch) Do ¶
Do runs the request through the transport, handle the response and returns a msearch.Response
func (*Msearch) ErrorTrace ¶ added in v8.14.0
ErrorTrace When set to `true` Elasticsearch will include the full stack trace of errors when they occur. API name: error_trace
func (*Msearch) ExpandWildcards ¶
func (r *Msearch) ExpandWildcards(expandwildcards ...expandwildcard.ExpandWildcard) *Msearch
ExpandWildcards Type of index that wildcard expressions can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. API name: expand_wildcards
func (*Msearch) FilterPath ¶ added in v8.14.0
FilterPath Comma-separated list of filters in dot notation which reduce the response returned by Elasticsearch. API name: filter_path
func (*Msearch) HttpRequest ¶
HttpRequest returns the http.Request object built from the given parameters.
func (*Msearch) Human ¶ added in v8.14.0
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 (*Msearch) IgnoreThrottled ¶
IgnoreThrottled If true, concrete, expanded or aliased indices are ignored when frozen. API name: ignore_throttled
func (*Msearch) IgnoreUnavailable ¶
IgnoreUnavailable If true, missing or closed indices are not included in the response. API name: ignore_unavailable
func (*Msearch) IncludeNamedQueriesScore ¶ added in v8.15.0
IncludeNamedQueriesScore Indicates whether hit.matched_queries should be rendered as a map that includes the name of the matched query associated with its score (true) or as an array containing the name of the matched queries (false) 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 of hits may add significant overhead. API name: include_named_queries_score
func (*Msearch) Index ¶
Index Comma-separated list of data streams, indices, and index aliases to search. API Name: index
func (*Msearch) MaxConcurrentSearches ¶
MaxConcurrentSearches Maximum number of concurrent searches the multi search API can execute. API name: max_concurrent_searches
func (*Msearch) MaxConcurrentShardRequests ¶
MaxConcurrentShardRequests Maximum number of concurrent shard requests that each sub-search request executes per node. API name: max_concurrent_shard_requests
func (Msearch) Perform ¶
Perform runs the http.Request through the provided transport and returns an http.Response.
func (*Msearch) PreFilterShardSize ¶
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 i.e., if date filters are mandatory to match but the shard bounds and the query are disjoint. API name: pre_filter_shard_size
func (*Msearch) Pretty ¶ added in v8.14.0
Pretty If set to `true` the returned JSON will be "pretty-formatted". Only use this option for debugging only. API name: pretty
func (*Msearch) Raw ¶
Raw takes a json payload as input which is then passed to the http.Request If specified Raw takes precedence on Request method.
func (*Msearch) RestTotalHitsAsInt ¶
RestTotalHitsAsInt If true, hits.total are returned as an integer in the response. Defaults to false, which returns an object. API name: rest_total_hits_as_int
func (*Msearch) Routing ¶
Routing Custom routing value used to route search operations to a specific shard. API name: routing
func (*Msearch) SearchType ¶
func (r *Msearch) SearchType(searchtype searchtype.SearchType) *Msearch
SearchType Indicates whether global term and document frequencies should be used when scoring returned documents. API name: search_type
type NewMsearch ¶
type NewMsearch func() *Msearch
NewMsearch type alias for index.
func NewMsearchFunc ¶
func NewMsearchFunc(tp elastictransport.Interface) NewMsearch
NewMsearchFunc returns a new instance of Msearch with the provided transport. Used in the index of the library this allows to retrieve every apis in once place.
type Request ¶ added in v8.11.0
type Request = []types.MsearchRequestItem
Request holds the request body struct for the package msearch
type Response ¶
type Response struct { Responses []types.MsearchResponseItem `json:"responses"` Took int64 `json:"took"` }
Response holds the response body struct for the package msearch