Documentation ¶
Index ¶
- Variables
- type AggResults
- type Bucket
- type Client
- func (cl *Client) AggregateDocumentByTerms(ctx context.Context, index string, fields []string) (*AggResults, error)
- func (cl *Client) CheckElasticSearchLiveness(ctx context.Context) error
- func (cl *Client) Count(ctx context.Context, indexName string) (*CountResponse, error)
- func (cl *Client) CreateIndex(ctx context.Context, index string, body io.Reader) error
- func (cl *Client) DeleteDocument(ctx context.Context, indexName string, documentID string) error
- func (cl *Client) DeleteDocumentByQuery(ctx context.Context, indexName string, body io.Reader) error
- func (cl *Client) GetDocument(ctx context.Context, indexName string, documentID string) (map[string]interface{}, error)
- func (cl *Client) IsIndexExists(ctx context.Context, index string) (bool, error)
- func (cl *Client) Refresh(ctx context.Context, indexName string) error
- func (cl *Client) SaveDocument(ctx context.Context, indexName string, documentID string, body io.Reader) error
- func (cl *Client) SearchDocument(ctx context.Context, indexName string, body io.Reader, options ...Option) (*SearchResponse, error)
- func (cl *Client) SearchDocumentByTerms(ctx context.Context, index string, keysAndValues map[string]any, ...) (*SearchResponse, error)
- type CountResponse
- type ESError
- type Hit
- type Hits
- type Option
- type SearchResponse
- type Total
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = &ESError{
StatusCode: 404,
Message: "Object not found",
}
Functions ¶
This section is empty.
Types ¶
type AggResults ¶
AggResults is assumed to be a struct that holds aggregation results.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents an Elasticsearch client that can perform various operations on the Elasticsearch cluster.
func (*Client) AggregateDocumentByTerms ¶
func (cl *Client) AggregateDocumentByTerms(ctx context.Context, index string, fields []string) (*AggResults, error)
AggregateDocumentByTerms performs an aggregation query based on the provided fields.
func (*Client) CheckElasticSearchLiveness ¶ added in v0.4.8
CheckElasticSearchLiveness would ping ElasticSearch client
func (*Client) CreateIndex ¶
CreateIndex creates a new index with the specified settings and mappings
func (*Client) DeleteDocument ¶
DeleteDocument deletes a document with the specified ID
func (*Client) DeleteDocumentByQuery ¶
func (cl *Client) DeleteDocumentByQuery( ctx context.Context, indexName string, body io.Reader, ) error
DeleteDocumentByQuery deletes documents from the specified index based on the provided query in the body.
func (*Client) GetDocument ¶
func (cl *Client) GetDocument( ctx context.Context, indexName string, documentID string, ) (map[string]interface{}, error)
GetDocument gets a document with the specified ID
func (*Client) IsIndexExists ¶
IsIndexExists Check if an index exists in Elasticsearch
func (*Client) SaveDocument ¶
func (cl *Client) SaveDocument( ctx context.Context, indexName string, documentID string, body io.Reader, ) error
SaveDocument saves a new document
func (*Client) SearchDocument ¶
func (cl *Client) SearchDocument( ctx context.Context, indexName string, body io.Reader, options ...Option, ) (*SearchResponse, error)
SearchDocument performs a search query in the specified index
func (*Client) SearchDocumentByTerms ¶
func (cl *Client) SearchDocumentByTerms(ctx context.Context, index string, keysAndValues map[string]any, options ...Option) (*SearchResponse, error)
SearchDocumentByTerms constructs a boolean search query with a must term match for each key-value pair in keyAndVal,
type CountResponse ¶
type CountResponse struct {
Count int64 `json:"count"`
}
CountResponse represents the response structure for a count operation.
type Hit ¶
type Hit struct { Index string `json:"_index"` ID string `json:"_id"` Score float32 `json:"_score"` Source map[string]interface{} `json:"_source"` }
Hit represents a single hit document from a search operation, containing index, ID, score, and source data.
type Hits ¶
type Hits struct { Total *Total `json:"total"` MaxScore float32 `json:"max_score"` Hits []*Hit `json:"hits"` }
Hits contains the hit documents and metadata from a search operation.
type Option ¶
type Option func(*config) error
func Pagination ¶
Pagination is a functional option to set the pagination configuration.