Documentation
¶
Overview ¶
Run a scrolling search.
IMPORTANT: The scroll API is no longer recommend for deep pagination. If you need to preserve the index state while paging through more than 10,000 hits, use the `search_after` parameter with a point in time (PIT).
The scroll API gets large sets of results from a single scrolling search request. To get the necessary scroll ID, submit a search API request that includes an argument for the `scroll` query parameter. The `scroll` parameter indicates how long Elasticsearch should retain the search context for the request. The search response returns a scroll ID in the `_scroll_id` response body parameter. You can then use the scroll ID with the scroll API to retrieve the next batch of results for the request. If the Elasticsearch security features are enabled, the access to the results of a specific scroll ID is restricted to the user or API key that submitted the search.
You can also use the scroll API to specify a new scroll parameter that extends or shortens the retention period for the search context.
IMPORTANT: Results from a scrolling search reflect the state of the index at the time of the initial search request. Subsequent indexing or document changes only affect later search and scroll requests.
Index ¶
- Variables
- type NewScroll
- type Request
- type Response
- type Scroll
- func (r Scroll) Do(providedCtx context.Context) (*Response, error)
- func (r *Scroll) ErrorTrace(errortrace bool) *Scroll
- func (r *Scroll) FilterPath(filterpaths ...string) *Scroll
- func (r *Scroll) Header(key, value string) *Scroll
- func (r *Scroll) HttpRequest(ctx context.Context) (*http.Request, error)
- func (r *Scroll) Human(human bool) *Scroll
- func (r Scroll) Perform(providedCtx context.Context) (*http.Response, error)
- func (r *Scroll) Pretty(pretty bool) *Scroll
- func (r *Scroll) Raw(raw io.Reader) *Scroll
- func (r *Scroll) Request(req *Request) *Scroll
- func (r *Scroll) RestTotalHitsAsInt(resttotalhitsasint bool) *Scroll
- func (r *Scroll) Scroll(duration types.DurationVariant) *Scroll
- func (r *Scroll) ScrollId(scrollid string) *Scroll
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 NewScroll ¶
type NewScroll func() *Scroll
NewScroll type alias for index.
func NewScrollFunc ¶
func NewScrollFunc(tp elastictransport.Interface) NewScroll
NewScrollFunc returns a new instance of Scroll 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 { // Scroll The period to retain the search context for scrolling. Scroll types.Duration `json:"scroll,omitempty"` // ScrollId The scroll ID of the search. ScrollId string `json:"scroll_id"` }
Request holds the request body struct for the package scroll
func (*Request) UnmarshalJSON ¶
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 The returned documents and metadata. 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_ 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. TimedOut bool `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 client Took int64 `json:"took"` }
Response holds the response body struct for the package scroll
func (*Response) UnmarshalJSON ¶
type Scroll ¶
type Scroll struct {
// contains filtered or unexported fields
}
func New ¶
func New(tp elastictransport.Interface) *Scroll
Run a scrolling search.
IMPORTANT: The scroll API is no longer recommend for deep pagination. If you need to preserve the index state while paging through more than 10,000 hits, use the `search_after` parameter with a point in time (PIT).
The scroll API gets large sets of results from a single scrolling search request. To get the necessary scroll ID, submit a search API request that includes an argument for the `scroll` query parameter. The `scroll` parameter indicates how long Elasticsearch should retain the search context for the request. The search response returns a scroll ID in the `_scroll_id` response body parameter. You can then use the scroll ID with the scroll API to retrieve the next batch of results for the request. If the Elasticsearch security features are enabled, the access to the results of a specific scroll ID is restricted to the user or API key that submitted the search.
You can also use the scroll API to specify a new scroll parameter that extends or shortens the retention period for the search context.
IMPORTANT: Results from a scrolling search reflect the state of the index at the time of the initial search request. Subsequent indexing or document changes only affect later search and scroll requests.
https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-scroll
func (Scroll) Do ¶
Do runs the request through the transport, handle the response and returns a scroll.Response
func (*Scroll) ErrorTrace ¶
ErrorTrace When set to `true` Elasticsearch will include the full stack trace of errors when they occur. API name: error_trace
func (*Scroll) FilterPath ¶
FilterPath Comma-separated list of filters in dot notation which reduce the response returned by Elasticsearch. API name: filter_path
func (*Scroll) HttpRequest ¶
HttpRequest returns the http.Request object built from the given parameters.
func (*Scroll) Human ¶
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 (Scroll) Perform ¶
Perform runs the http.Request through the provided transport and returns an http.Response.
func (*Scroll) Pretty ¶
Pretty If set to `true` the returned JSON will be "pretty-formatted". Only use this option for debugging only. API name: pretty
func (*Scroll) 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 (*Scroll) RestTotalHitsAsInt ¶
RestTotalHitsAsInt If true, the API response’s hit.total property is returned as an integer. If false, the API response’s hit.total property is returned as an object. API name: rest_total_hits_as_int