Documentation
¶
Index ¶
- Constants
- Variables
- func Ptr[T any](i T) *T
- type Aggregation
- type BoolFilter
- type BulkIndex
- type BulkItem
- type BulkResponse
- type BulkResponseItem
- type CardinalityAgg
- type CausedBy
- type Client
- func (ec *Client) CloseIndex(ctx context.Context, index string) error
- func (ec *Client) Count(ctx context.Context, index string) (int, error)
- func (ec *Client) CreateIndex(ctx context.Context, index string, body map[string]any) error
- func (ec *Client) DeleteByQuery(ctx context.Context, req *DeleteByQueryRequest) error
- func (ec *Client) DeleteIndex(ctx context.Context, index []string) error
- func (ec *Client) GetIndexAlias(ctx context.Context, name string) (map[string]any, error)
- func (ec *Client) GetIndexMappings(ctx context.Context, index string) (*Mappings, error)
- func (ec *Client) GetIndicesStats(ctx context.Context, indexPattern string) ([]IndexStats, error)
- func (ec *Client) Index(ctx context.Context, req *IndexRequest) error
- func (ec *Client) IndexExists(ctx context.Context, index string) (bool, error)
- func (ec *Client) IndexWithID(ctx context.Context, req *IndexWithIDRequest) error
- func (ec *Client) ListIndices(ctx context.Context, indices []string) ([]string, error)
- func (ec *Client) Perform(req *http.Request) (*http.Response, error)
- func (ec *Client) PutIndexAlias(ctx context.Context, index []string, name string) error
- func (ec *Client) PutIndexMappings(ctx context.Context, index string, mapping map[string]any) error
- func (ec *Client) PutIndexSettings(ctx context.Context, index string, settings map[string]any) error
- func (ec *Client) RefreshIndex(ctx context.Context, index string) error
- func (ec *Client) Search(ctx context.Context, req *SearchRequest) (*SearchResponse, error)
- func (ec *Client) SendBulkRequest(ctx context.Context, items []BulkItem) ([]BulkItem, error)
- type Condition
- type DateHistogramAgg
- type DeleteByQueryRequest
- type ESPercentilesAgg
- type ErrIllegalArgument
- type ErrQueryInvalid
- type ErrResourceAlreadyExists
- type ExistsFilter
- type ExpFunction
- type FieldValueFactor
- type Function
- type FunctionScore
- type Highlight
- type HistogramAgg
- type Hit
- type Hits
- type IndexRequest
- type IndexStats
- type IndexWithIDRequest
- type KNNQuery
- type Mappings
- type MultiMatch
- type Query
- type QueryBody
- type ResponseError
- type RetryableError
- type RootCause
- type Script
- type ScriptScore
- type SearchClient
- type SearchRequest
- type SearchResponse
- type Sort
- type SumMinMaxAgg
- type TermsAgg
Constants ¶
View Source
const ( SearchExecutionException = "search_phase_execution_exception" TooManyBucketsException = "too_many_buckets_exception" TooManyNestedClausesException = "too_many_nested_clauses" TooManyClausesException = "too_many_clauses" IllegalArgumentException = "illegal_argument_exception" SnapshotInProgressException = "snapshot_in_progress_exception" ResourceAlreadyExistsException = "resource_already_exists_exception" )
Variables ¶
View Source
var ( ErrTooManyRequests = errors.New("too many requests") ErrTooManyBuckets = errors.New("too many buckets") ErrTooManyNestedClauses = errors.New("too many nested clauses") ErrTooManyClauses = errors.New("too many clauses") )
View Source
var (
ErrResourceNotFound = errors.New("elasticsearch resource not found")
)
Functions ¶
Types ¶
type Aggregation ¶
type Aggregation struct {
Filter *Condition `json:"filter,omitempty"`
Cardinality *CardinalityAgg `json:"cardinality,omitempty"`
DateHistogram *DateHistogramAgg `json:"date_histogram,omitempty"`
Sum *SumMinMaxAgg `json:"sum,omitempty"`
Min *SumMinMaxAgg `json:"min,omitempty"`
Max *SumMinMaxAgg `json:"max,omitempty"`
Avg *SumMinMaxAgg `json:"avg,omitempty"`
Percentiles *ESPercentilesAgg `json:"percentiles,omitempty"`
Terms *TermsAgg `json:"terms,omitempty"`
Histogram *HistogramAgg `json:"histogram,omitempty"`
Aggs map[string]Aggregation `json:"aggs,omitempty"`
}
type BoolFilter ¶
type BulkResponse ¶
type BulkResponse struct {
Errors bool `json:"errors"`
Items []BulkResponseItem
}
type BulkResponseItem ¶
type BulkResponseItem struct {
Index struct {
Status int `json:"status"`
Error json.RawMessage `json:"error"`
} `json:"index"`
Delete struct {
Status int `json:"status"`
Error json.RawMessage `json:"error"`
} `json:"delete"`
}
type CardinalityAgg ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) CreateIndex ¶
func (*Client) DeleteByQuery ¶
func (ec *Client) DeleteByQuery(ctx context.Context, req *DeleteByQueryRequest) error
func (*Client) DeleteIndex ¶
func (*Client) GetIndexAlias ¶
func (*Client) GetIndexMappings ¶
func (*Client) GetIndicesStats ¶
GetIndicesStats uses the index stats API to fetch statistics about indices. indexPattern is a wildcard pattern used to select the indices we care about.
func (*Client) IndexExists ¶
func (*Client) IndexWithID ¶
func (ec *Client) IndexWithID(ctx context.Context, req *IndexWithIDRequest) error
func (*Client) ListIndices ¶
ListIndices returns the list of indices that match the index name pattern on input from the OS cluster
func (*Client) PutIndexAlias ¶
func (*Client) PutIndexMappings ¶
PutIndexMappings add field type mapping data to a previously created ES index Dynamic mapping is disabled upon index creation, so it is a requirement to explicitly define mappings for each column
func (*Client) PutIndexSettings ¶
func (*Client) RefreshIndex ¶
func (*Client) Search ¶
func (ec *Client) Search(ctx context.Context, req *SearchRequest) (*SearchResponse, error)
type Condition ¶
type Condition struct {
Term map[string]any `json:"term,omitempty"`
Terms map[string]any `json:"terms,omitempty"`
Prefix map[string]any `json:"prefix,omitempty"`
Wildcard map[string]any `json:"wildcard,omitempty"`
IDs map[string]any `json:"ids,omitempty"`
Range map[string]any `json:"range,omitempty"`
Exists *ExistsFilter `json:"exists,omitempty"`
Bool *BoolFilter `json:"bool,omitempty"`
MultiMatch *MultiMatch `json:"multi_match,omitempty"`
}
type DateHistogramAgg ¶
type DeleteByQueryRequest ¶
type ESPercentilesAgg ¶
type ErrIllegalArgument ¶
type ErrIllegalArgument struct {
Reason string
}
func (*ErrIllegalArgument) Error ¶
func (e *ErrIllegalArgument) Error() string
type ErrQueryInvalid ¶
type ErrQueryInvalid struct {
Cause error
}
func (ErrQueryInvalid) Error ¶
func (e ErrQueryInvalid) Error() string
type ErrResourceAlreadyExists ¶
type ErrResourceAlreadyExists struct {
Reason string
}
func (ErrResourceAlreadyExists) Error ¶
func (e ErrResourceAlreadyExists) Error() string
type ExistsFilter ¶
type ExistsFilter struct {
Field string `json:"field"`
}
type ExpFunction ¶
type FieldValueFactor ¶
type Function ¶
type Function struct {
Filter *Condition `json:"filter,omitempty"`
FieldValueFactor *FieldValueFactor `json:"field_value_factor,omitempty"`
Weight *float64 `json:"weight,omitempty"`
Exp map[string]ExpFunction `json:"exp,omitempty"`
}
type FunctionScore ¶
type HistogramAgg ¶
type IndexRequest ¶
type IndexStats ¶
type IndexWithIDRequest ¶
type MultiMatch ¶
type Query ¶
type Query struct {
Bool *BoolFilter `json:"bool,omitempty"`
FunctionScore *FunctionScore `json:"function_score,omitempty"`
ScriptScore *ScriptScore `json:"script_score,omitempty"`
KNN *map[string]KNNQuery `json:"knn,omitempty"`
}
type ResponseError ¶
type RetryableError ¶
type RetryableError struct {
Cause error
}
func (RetryableError) Error ¶
func (r RetryableError) Error() string
func (RetryableError) Unwrap ¶
func (r RetryableError) Unwrap() error
type ScriptScore ¶
type ScriptScore struct {
Query json.RawMessage `json:"query,omitempty"`
Script *Script `json:"script,omitempty"`
}
type SearchClient ¶
type SearchClient interface {
CloseIndex(ctx context.Context, index string) error
Count(ctx context.Context, index string) (int, error)
CreateIndex(ctx context.Context, index string, body map[string]any) error
DeleteByQuery(ctx context.Context, req *DeleteByQueryRequest) error
DeleteIndex(ctx context.Context, index []string) error
GetIndexAlias(ctx context.Context, name string) (map[string]any, error)
GetIndexMappings(ctx context.Context, index string) (*Mappings, error)
GetIndicesStats(ctx context.Context, indexPattern string) ([]IndexStats, error)
Index(ctx context.Context, req *IndexRequest) error
IndexWithID(ctx context.Context, req *IndexWithIDRequest) error
IndexExists(ctx context.Context, index string) (bool, error)
ListIndices(ctx context.Context, indices []string) ([]string, error)
Perform(req *http.Request) (*http.Response, error)
PutIndexAlias(ctx context.Context, index []string, name string) error
PutIndexMappings(ctx context.Context, index string, body map[string]any) error
PutIndexSettings(ctx context.Context, index string, body map[string]any) error
RefreshIndex(ctx context.Context, index string) error
Search(ctx context.Context, req *SearchRequest) (*SearchResponse, error)
SendBulkRequest(ctx context.Context, items []BulkItem) ([]BulkItem, error)
}
type SearchRequest ¶
type SearchResponse ¶
type SumMinMaxAgg ¶
type SumMinMaxAgg struct {
Field string `json:"field"`
}
Click to show internal directories.
Click to hide internal directories.