Movatterモバイル変換


[0]ホーム

URL:


Notice  The highest tagged major version isv9.

scroll

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:12Imported by:7

Details

Repository

github.com/elastic/go-elasticsearch

Links

Documentation

Overview

Run a scrolling search.

IMPORTANT: The scroll API is no longer recommend for deep pagination. If youneed 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 searchrequest.To get the necessary scroll ID, submit a search API request that includes anargument for the `scroll` query parameter.The `scroll` parameter indicates how long Elasticsearch should retain thesearch context for the request.The search response returns a scroll ID in the `_scroll_id` response bodyparameter.You can then use the scroll ID with the scroll API to retrieve the next batchof results for the request.If the Elasticsearch security features are enabled, the access to the resultsof a specific scroll ID is restricted to the user or API key that submittedthe search.

You can also use the scroll API to specify a new scroll parameter thatextends or shortens the retention period for the search context.

IMPORTANT: Results from a scrolling search reflect the state of the index atthe time of the initial search request. Subsequent indexing or documentchanges only affect later search and scroll requests.

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

typeNewScroll

type NewScroll func() *Scroll

NewScroll type alias for index.

funcNewScrollFunc

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

typeRequest

type Request struct {// Scroll The period to retain the search context for scrolling.Scrolltypes.Duration `json:"scroll,omitempty"`// ScrollId The scroll ID of the search.ScrollIdstring `json:"scroll_id"`}

Request holds the request body struct for the package scroll

https://github.com/elastic/elasticsearch-specification/blob/470b4b9aaaa25cae633ec690e54b725c6fc939c7/specification/_global/scroll/ScrollRequest.ts#L24-L88

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 scroll

https://github.com/elastic/elasticsearch-specification/blob/470b4b9aaaa25cae633ec690e54b725c6fc939c7/specification/_global/scroll/ScrollResponse.ts#L22-L24

funcNewResponseadded inv8.7.0

func NewResponse() *Response

NewResponse returns a Response

func (*Response)UnmarshalJSONadded inv8.7.0

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

typeScroll

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

funcNew

Run a scrolling search.

IMPORTANT: The scroll API is no longer recommend for deep pagination. If youneed 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 searchrequest.To get the necessary scroll ID, submit a search API request that includes anargument for the `scroll` query parameter.The `scroll` parameter indicates how long Elasticsearch should retain thesearch context for the request.The search response returns a scroll ID in the `_scroll_id` response bodyparameter.You can then use the scroll ID with the scroll API to retrieve the next batchof results for the request.If the Elasticsearch security features are enabled, the access to the resultsof a specific scroll ID is restricted to the user or API key that submittedthe search.

You can also use the scroll API to specify a new scroll parameter thatextends or shortens the retention period for the search context.

IMPORTANT: Results from a scrolling search reflect the state of the index atthe time of the initial search request. Subsequent indexing or documentchanges only affect later search and scroll requests.

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

func (Scroll)Do

func (rScroll) Do(providedCtxcontext.Context) (*Response,error)

Do runs the request through the transport, handle the response and returns a scroll.Response

func (*Scroll)ErrorTraceadded inv8.14.0

func (r *Scroll) ErrorTrace(errortracebool) *Scroll

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

func (*Scroll)FilterPathadded inv8.14.0

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

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

func (*Scroll)Header

func (r *Scroll) Header(key, valuestring) *Scroll

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

func (*Scroll)HttpRequest

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

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

func (*Scroll)Humanadded inv8.14.0

func (r *Scroll) Human(humanbool) *Scroll

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 (Scroll)Performadded inv8.7.0

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

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

func (*Scroll)Prettyadded inv8.14.0

func (r *Scroll) Pretty(prettybool) *Scroll

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

func (*Scroll)Raw

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

Raw takes a json payload as input which is then passed to the http.RequestIf specified Raw takes precedence on Request method.

func (*Scroll)Request

func (r *Scroll) Request(req *Request) *Scroll

Request allows to set the request property with the appropriate payload.

func (*Scroll)RestTotalHitsAsInt

func (r *Scroll) RestTotalHitsAsInt(resttotalhitsasintbool) *Scroll

RestTotalHitsAsInt If true, the API response’s hit.total property is returned as an integer. Iffalse, the API response’s hit.total property is returned as an object.API name: rest_total_hits_as_int

func (*Scroll)Scroll

func (r *Scroll) Scroll(durationtypes.Duration) *Scroll

Scroll The period to retain the search context for scrolling.API name: scroll

func (*Scroll)ScrollId

func (r *Scroll) ScrollId(scrollidstring) *Scroll

ScrollId The scroll ID of the search.API name: scroll_id

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