doc

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create[T ~string, O opensearch.Doc[T]](
	ctx context.Context,
	client opensearchapi.DocumentClient,
	index string,
	doc O,
) error

Create will create the given document, with given id, in the given index. If a document with the given ID already exists, it will return a 409 error. Use Index to "upsert" a doc where it might already exists.

https://docs.opensearch.org/latest/api-reference/document-apis/index-document/

func Delete

func Delete[T ~string](
	ctx context.Context,
	client opensearchapi.DocumentClient,
	index string,
	id T,
	options ...DeleteOption,
) error

Delete performs a document deletion request.

https://docs.opensearch.org/latest/api-reference/document-apis/delete-document/

func DeleteByQuery

func DeleteByQuery(ctx context.Context, client Client, index string, options ...DeleteByQueryOption) error

DeleteByQuery performs a delete by query request on the given index with the given options.

https://docs.opensearch.org/latest/api-reference/document-apis/delete-by-query/

func Get

func Get[T ~string, O opensearch.Doc[T]](
	ctx context.Context,
	client opensearchapi.DocumentClient,
	index string,
	id T,
) (O, error)

Get will retrieve the document with the given ID from the given index.

https://docs.opensearch.org/latest/api-reference/document-apis/get-documents/

func GetDocs added in v0.262.0

func GetDocs[T ~string, O opensearch.Doc[T]](
	ctx context.Context,
	client opensearchapi.DocumentClient,
	index string,
	ids ...T,
) ([]O, error)

GetDocs will retrieve the documents with the given IDs from the given index.

https://docs.opensearch.org/latest/api-reference/document-apis/multi-get/

func Index added in v0.261.0

func Index[T ~string, O opensearch.Doc[T]](
	ctx context.Context,
	client opensearchapi.DocumentClient,
	index string,
	doc O,
	options ...IndexOption,
) error

Index will create the given document, with given id, in the given index. If a document with the ID already exists, it will be overridden.

https://docs.opensearch.org/latest/api-reference/document-apis/index-document/

func Update

func Update[T ~string](
	ctx context.Context,
	client opensearchapi.DocumentClient,
	index string,
	id T,
	doc any,
	options ...UpdateOption,
) error

Update will apply the updates to the doc with the given id.

https://docs.opensearch.org/latest/api-reference/document-apis/update-document/

Types

type Client

type Client interface {
	DeleteByQuery(ctx context.Context, req *opensearchapi.DeleteByQueryReq) (*opensearchapi.DeleteByQueryResp, error)
}

type DeleteByQueryOption

type DeleteByQueryOption func(*opensearchapi.DeleteByQueryBody)

DeleteByQueryOption is a functional option applied to a DeleteByQuery request.

func WithDeleteByQuery

func WithDeleteByQuery(options ...search.QueryOption) DeleteByQueryOption

WithDeleteByQuery option specifies the query used to select documents to delete.

func WithDeleteMaxDocs

func WithDeleteMaxDocs(max int) DeleteByQueryOption

WithDeleteMaxDocs options specifies the maximum number of documents to delete.

type DeleteOption

type DeleteOption func(*opensearchapi.DeleteParams)

DeleteOption is a functional option applied to a Delete request.

func WithDeletePrimaryTerm

func WithDeletePrimaryTerm(term int) DeleteOption

WithDeletePrimaryTerm option ensures the deletion will only happen if the document has the given primary term.

func WithDeleteRefresh added in v0.261.0

func WithDeleteRefresh(refresh opensearchapi.Refresh) DeleteOption

WithDeleteRefresh option sets the refresh value for the delete operation.

func WithDeleteSeqNo

func WithDeleteSeqNo(num int) DeleteOption

WithDeleteSeqNo option ensures the deletion will only happen if the document has the given sequence number.

type IndexOption added in v0.261.0

type IndexOption func(*opensearchapi.IndexReq)

IndexOption is a functional option applied to an Index request.

func WithIndexRefresh added in v0.261.0

func WithIndexRefresh(value opensearchapi.Refresh) IndexOption

WithIndexRefresh option sets the refresh value for the index operation.

type UpdateOption

type UpdateOption func(*opensearchapi.UpdateBody)

UpdateOption is a functional option to apply to an Update request.

func WithDocAsUpsert

func WithDocAsUpsert(value bool) UpdateOption

WithDocAsUpsert will add the doc as a new document if not found. Otherwise, the doc will be updated.

func WithUpdateDetectNoop added in v0.261.0

func WithUpdateDetectNoop(value bool) UpdateOption

WithUpdateDetectNoop option if set to `false` to disable setting `result` in the response to `noop` if no change to the document occurred.

Jump to

Keyboard shortcuts

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