Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connector ¶
type Connector interface {
Req(path string) httpclient.HTTPRequest
}
type Error ¶
type Error struct {
Err ErrorDetails `json:"error"`
Status int64 `json:"status"`
}
type ErrorDetails ¶
type ErrorDetails struct {
RootCause []ErrorDetails `json:"root_cause,omitempty"`
Type string `json:"type"`
Reason string `json:"reason"`
IndexUUID string `json:"index_uuid"`
Index string `json:"index"`
}
type Filters ¶
type Filters struct {
// Key is the field to be filtered.
Key string
// Value is the value to be filtered.
Value any
}
Filters is a filter to be applied on the data.
type Index ¶
type Index[T any] interface { // Upsert - add or update a document in the index. // - ctx: the context of the request. // - id: the id of the document. // - doc: the document body to be added or updated. Upsert( ctx context.Context, id string, doc T, ) error // Fetch - fetches a document from the index. // - ctx: the context of the request. // - id: the id of the document. // Returns: // - document: an option of the document, can be None if not found. // - error: an error if any. Not found is not considered an error and is represented by the None option Fetch( ctx context.Context, id string, ) (gopts.Option[T], error) // Delete - deletes one or many documents from the index. // - ctx: the context of the request. // - ids: the ids of the documents to be deleted. multi argument field for multiple ids. Delete( ctx context.Context, ids ...string, ) error // List - retrieves one or many documents from the index. // - ctx: the context of the request. // - ids: the ids of the documents to be retrieved. multi argument field for multiple ids. // Returns: // - list: a list of documents. // - error: an error if any. List( ctx context.Context, ids ...string, ) ([]T, error) // Query - queries the index with the given query. // - ctx: the context of the request. // - query: the query to be executed // Returns: // - list: a list of documents. // - error: an error if any. Query( ctx context.Context, query Queryable, ) (QueryResult[T], error) // Ensure - ensures the index exists. // Returns: // - error: an error if any. Ensure() error // Client - Returns an HTTP Client to be build // - endpoint: the elastic endpoint // Returns: // - httpclient.HTTPRequest Client(endpoint string) httpclient.HTTPRequest // Name - Returns the Index name // Returns: // - string Name() string }
type QueryBody ¶
type QueryBody struct {
// Searches is a list of strings to be partially matched.
Searches []string
// Ranges is a range filter to be applied on the data.
Ranges []Range
// Equal is a list of filters to be applied on the data.
Equal []Filters
// NotEqual is a list of filters to be excluded from the data.
NotEqual []Filters
// In is a list of filters where the value should match any of the values
// in an OR fashion
In []Filters
}
QueryBody is the query body to be applied on the data.
type QueryResult ¶ added in v0.0.2
type QueryResult[T any] struct { // Data is the list of documents. Data []T // Total is the total number of documents. Total int }
QueryResult is the **paged* response of the query.
type Queryable ¶
type Queryable struct {
// From is the starting index of the data to be fetched. Default is 0.
// Size is the number of data to be fetched. Default is 1000.
From, Size gopts.Option[int]
// SortingOptions is a list of sorting options to be applied on the data.
SortingOptions []SortingOptions
// Search is the query body to be applied on the data.
Search QueryBody
}
Queryable is a description of the query you would like to perform on the index data
type Range ¶
type Range struct {
// Key is the field to be ranged.
Key string
// Gte is the greater than or equal to value.
// Lte is the less than or equal to value.
Gte, Lte gopts.Option[any]
}
Range is a range filter to be applied on the data.
type SortingOptions ¶
type SortingOptions struct {
// SortField is the field to be sorted.
SortField, SortOrder gopts.Option[string]
}
SortingOptions is a list of sorting options to be applied on the data.
Click to show internal directories.
Click to hide internal directories.