mget

package
v0.1.1-20231031 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Allows to get multiple documents in one request.

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 Mget

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

func (Mget) Do

func (r Mget) Do(ctx context.Context) (*Response, error)

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

func (*Mget) Docs

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

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

func (*Mget) Header

func (r *Mget) Header(key, value string) *Mget

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

func (*Mget) HttpRequest

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

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

func (*Mget) Ids

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

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

func (*Mget) Index

func (r *Mget) Index(index string) *Mget

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

func (Mget) Perform

func (r Mget) Perform(ctx context.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(preference string) *Mget

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

func (*Mget) Raw

func (r *Mget) Raw(raw io.Reader) *Mget

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

func (*Mget) Realtime

func (r *Mget) Realtime(realtime bool) *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(refresh bool) *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(routing string) *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 specified in `_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. You can exclude fields from this subset using the `_source_excludes` query parameter. If the `_source` parameter is `false`, this parameter is ignored. API name: _source_includes

func (*Mget) Source_

func (r *Mget) Source_(sourceconfigparam string) *Mget

Source_ True or false to return the `_source` field or not, or a list of fields to return. 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 the document `_source`. API name: stored_fields

type NewMget

type NewMget func() *Mget

NewMget type alias for index.

func NewMgetFunc

func NewMgetFunc(tp elastictransport.Interface) NewMget

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.

type Request

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/0f7969a4e10ecb4423057d4ad29744c4a7c3c67b/specification/_global/mget/MultiGetRequest.ts#L25-L91

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 {
	Docs []types.MgetResponseItem `json:"docs"`
}

func NewResponse

func NewResponse() *Response

NewResponse returns a Response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL