Documentation
¶
Index ¶
- func Create[T ~string, O opensearch.Doc[T]](ctx context.Context, client opensearchapi.DocumentClient, index string, doc O) error
- func Delete[T ~string](ctx context.Context, client opensearchapi.DocumentClient, index string, id T, ...) error
- func DeleteByQuery(ctx context.Context, client Client, index string, ...) error
- func Get[T ~string, O opensearch.Doc[T]](ctx context.Context, client opensearchapi.DocumentClient, index string, id T) (O, error)
- func GetDocs[T ~string, O opensearch.Doc[T]](ctx context.Context, client opensearchapi.DocumentClient, index string, ...) ([]O, error)
- func Index[T ~string, O opensearch.Doc[T]](ctx context.Context, client opensearchapi.DocumentClient, index string, doc O, ...) error
- func Update[T ~string](ctx context.Context, client opensearchapi.DocumentClient, index string, id T, ...) error
- type Client
- type DeleteByQueryOption
- type DeleteOption
- type IndexOption
- type UpdateOption
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.