Movatterモバイル変換


[0]ホーム

URL:


Notice  The highest tagged major version isv9.

mget

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:6

Details

Repository

github.com/elastic/go-elasticsearch

Links

Documentation

Overview

Get multiple documents.

Get multiple JSON documents by ID from one or more indices.If you specify an index in the request URI, you only need to specify thedocument IDs in the request body.To ensure fast responses, this multi get (mget) API responds with partialresults if one or more shards fail.

**Filter source fields**

By default, the `_source` field is returned for every document (if stored).Use the `_source` and `_source_include` or `source_exclude` attributes tofilter what fields are returned for a particular document.You can include the `_source`, `_source_includes`, and `_source_excludes`query parameters in the request URI to specify the defaults to use when thereare no per-document instructions.

**Get stored fields**

Use the `stored_fields` attribute to specify the set of stored fields youwant to retrieve.Any requested fields that are not stored are ignored.You can include the `stored_fields` query parameter in the request URI tospecify the defaults to use when there are no per-document instructions.

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

typeMget

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

funcNew

Get multiple documents.

Get multiple JSON documents by ID from one or more indices.If you specify an index in the request URI, you only need to specify thedocument IDs in the request body.To ensure fast responses, this multi get (mget) API responds with partialresults if one or more shards fail.

**Filter source fields**

By default, the `_source` field is returned for every document (if stored).Use the `_source` and `_source_include` or `source_exclude` attributes tofilter what fields are returned for a particular document.You can include the `_source`, `_source_includes`, and `_source_excludes`query parameters in the request URI to specify the defaults to use when thereare no per-document instructions.

**Get stored fields**

Use the `stored_fields` attribute to specify the set of stored fields youwant to retrieve.Any requested fields that are not stored are ignored.You can include the `stored_fields` query parameter in the request URI tospecify the defaults to use when there are no per-document instructions.

https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html

func (Mget)Do

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

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

func (*Mget)Docsadded inv8.9.0

func (r *Mget) Docs(docs ...types.MgetOperation) *Mget

Docs The documents you want to retrieve. Required if no index is specified in therequest URI.API name: docs

func (*Mget)ErrorTraceadded inv8.14.0

func (r *Mget) ErrorTrace(errortracebool) *Mget

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

func (*Mget)FilterPathadded inv8.14.0

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

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

func (*Mget)ForceSyntheticSourceadded inv8.13.1

func (r *Mget) ForceSyntheticSource(forcesyntheticsourcebool) *Mget

ForceSyntheticSource Should this request force synthetic _source?Use this to test if the mapping supports synthetic _source and to get a senseof the worst case performance.Fetches with this enabled will be slower the enabling synthetic sourcenatively in the index.API name: force_synthetic_source

func (*Mget)Header

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

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

func (*Mget)HttpRequest

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

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

func (*Mget)Humanadded inv8.14.0

func (r *Mget) Human(humanbool) *Mget

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 (*Mget)Idsadded inv8.9.0

func (r *Mget) Ids(ids ...string) *Mget

Ids The IDs of the documents you want to retrieve. Allowed when the index isspecified in the request URI.API name: ids

func (*Mget)Index

func (r *Mget) Index(indexstring) *Mget

Index Name of the index to retrieve documents from when `ids` are specified, orwhen a document in the `docs` array does not specify an index.API Name: index

func (Mget)Performadded inv8.7.0

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

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

func (*Mget)Preference

func (r *Mget) Preference(preferencestring) *Mget

Preference Specifies the node or shard the operation should be performed on. Random bydefault.API name: preference

func (*Mget)Prettyadded inv8.14.0

func (r *Mget) Pretty(prettybool) *Mget

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

func (*Mget)Raw

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

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

func (*Mget)Realtime

func (r *Mget) Realtime(realtimebool) *Mget

Realtime If `true`, the request is real-time as opposed to near-real-time.API name: realtime

func (*Mget)Refresh

func (r *Mget) Refresh(refreshbool) *Mget

Refresh If `true`, the request refreshes relevant shards before retrieving documents.API name: refresh

func (*Mget)Request

func (r *Mget) Request(req *Request) *Mget

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

func (*Mget)Routing

func (r *Mget) Routing(routingstring) *Mget

Routing Custom value used to route operations to a specific shard.API name: routing

func (*Mget)SourceExcludes_

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

SourceExcludes_ A comma-separated list of source fields to exclude from the response.You can also use this parameter to exclude fields from the subset specifiedin `_source_includes` query parameter.API name: _source_excludes

func (*Mget)SourceIncludes_

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

SourceIncludes_ A comma-separated list of source fields to include in the response.If this parameter is specified, only these source fields are returned. Youcan exclude fields from this subset using the `_source_excludes` queryparameter.If the `_source` parameter is `false`, this parameter is ignored.API name: _source_includes

func (*Mget)Source_

func (r *Mget) Source_(sourceconfigparamstring) *Mget

Source_ True or false to return the `_source` field or not, or a list of fields toreturn.API name: _source

func (*Mget)StoredFields

func (r *Mget) StoredFields(fields ...string) *Mget

StoredFields If `true`, retrieves the document fields stored in the index rather than thedocument `_source`.API name: stored_fields

typeNewMget

type NewMget func() *Mget

NewMget type alias for index.

funcNewMgetFunc

NewMgetFunc returns a new instance of Mget with the provided transport.Used in the index of the library this allows to retrieve every apis in once place.

typeRequest

type Request struct {// Docs The documents you want to retrieve. Required if no index is specified in the// request URI.Docs []types.MgetOperation `json:"docs,omitempty"`// Ids The IDs of the documents you want to retrieve. Allowed when the index is// specified in the request URI.Ids []string `json:"ids,omitempty"`}

Request holds the request body struct for the package mget

https://github.com/elastic/elasticsearch-specification/blob/470b4b9aaaa25cae633ec690e54b725c6fc939c7/specification/_global/mget/MultiGetRequest.ts#L25-L127

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 {// Docs The response includes a docs array that contains the documents in the order// specified in the request.// The structure of the returned documents is similar to that returned by the// get API.// If there is a failure getting a particular document, the error is included in// place of the document.Docs []types.MgetResponseItem `json:"docs"`}

Response holds the response body struct for the package mget

https://github.com/elastic/elasticsearch-specification/blob/470b4b9aaaa25cae633ec690e54b725c6fc939c7/specification/_global/mget/MultiGetResponse.ts#L22-L31

funcNewResponseadded inv8.7.0

func NewResponse() *Response

NewResponse returns a Response

func (*Response)UnmarshalJSONadded inv8.12.0

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

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