Documentation ¶
Index ¶
- Constants
- Variables
- type ClusterHealth
- type ESClient
- func (cli *ESClient) AddDocument(ctx context.Context, indexName, documentID string, document []byte, ...) error
- func (cli *ESClient) BulkIndexAdd(ctx context.Context, action client.BulkIndexerAction, index, documentID string, ...) error
- func (cli *ESClient) BulkIndexClose(ctx context.Context) error
- func (cli *ESClient) BulkUpdate(ctx context.Context, indexName, esURL string, payload []byte) ([]byte, error)
- func (cli *ESClient) Checker(ctx context.Context, state *health.CheckState) error
- func (cli *ESClient) CountIndices(ctx context.Context, indices []string) ([]byte, error)
- func (cli *ESClient) CreateIndex(ctx context.Context, indexName string, indexSettings []byte) error
- func (cli *ESClient) DeleteIndex(ctx context.Context, indexName string) error
- func (cli *ESClient) DeleteIndices(ctx context.Context, indices []string) error
- func (cli *ESClient) GetAlias(ctx context.Context) ([]byte, error)
- func (cli *ESClient) GetIndices(ctx context.Context, indexPatterns []string) ([]byte, error)
- func (cli *ESClient) MultiSearch(ctx context.Context, searches []client.Search) ([]byte, error)
- func (cli *ESClient) NewBulkIndexer(ctx context.Context) error
- func (cli *ESClient) Search(ctx context.Context, search client.Search) ([]byte, error)
- func (cli *ESClient) UpdateAliases(ctx context.Context, alias string, removeIndices, addIndices []string) error
- type HealthStatus
Constants ¶
const ( Create = client.BulkIndexerAction("create") Delete = client.BulkIndexerAction("delete") Index = client.BulkIndexerAction("index") Update = client.BulkIndexerAction("update") )
const ( HealthGreen = iota HealthYellow HealthRed )
Possible values for the HealthStatus
const MsgHealthy = "elasticsearch is healthy and the required indexes exist"
MsgHealthy Check message returned when elasticsearch is healthy and the required indexes exist
Variables ¶
var ( ErrorUnexpectedStatusCode = errors.New("unexpected status code from api") ErrorParsingBody = errors.New("error parsing cluster health response body") ErrorClusterAtRisk = errors.New("elasticsearch cluster state yellow but functional. Data might be at risk, check your replica shards") ErrorUnhealthyClusterStatus = errors.New("error cluster health red. Cluster is unhealthy") ErrorInvalidHealthStatus = errors.New("error invalid health status returned") ErrorIndexDoesNotExist = errors.New("error index does not exist in cluster") ErrorInternalServer = errors.New("error internal server error") )
List of errors
Functions ¶
This section is empty.
Types ¶
type ClusterHealth ¶
type ClusterHealth struct {
Status string `json:"status"`
}
ClusterHealth represents the response from the elasticsearch cluster health check
type ESClient ¶
type ESClient struct {
// contains filtered or unexported fields
}
func NewESClient ¶
func NewESClient(esURL string, transport http.RoundTripper) (*ESClient, error)
NewESClient returns a new elastic search client version 7.10
func (*ESClient) AddDocument ¶
func (cli *ESClient) AddDocument(ctx context.Context, indexName, documentID string, document []byte, options *client.AddDocumentOptions) error
AddDocument adds a document to the index specified. Upsert option not implemented. See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/7.10/docs-update.html.
func (*ESClient) BulkIndexAdd ¶
func (cli *ESClient) BulkIndexAdd(ctx context.Context, action client.BulkIndexerAction, index, documentID string, document []byte) error
Add adds an item to the indexer. It returns an error when the item cannot be added. Use the OnSuccess and OnFailure callbacks to get the operation result for the item.
You must call the Close() method after you're done adding items.
It is safe for concurrent use. When it's called from goroutines, they must finish before the call to Close, eg. using sync.WaitGroup.
func (*ESClient) BulkIndexClose ¶
Close waits until all added items are flushed and closes the indexer.
func (*ESClient) BulkUpdate ¶
func (cli *ESClient) BulkUpdate(ctx context.Context, indexName, esURL string, payload []byte) ([]byte, error)
Bulk allows to perform multiple index/update/delete operations in a single request. See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/7.10/docs-bulk.html.
func (*ESClient) Checker ¶
Checker checks health of Elasticsearch, if the required indexes exist and updates the provided CheckState accordingly.
func (*ESClient) CountIndices ¶
Count returns number of documents matching a query.
See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/search-count.html.
func (*ESClient) CreateIndex ¶
IndicesCreate creates an index with optional settings and mappings. See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/7.10/indices-create-index.html.
func (*ESClient) DeleteIndex ¶
IndicesDelete deletes an index. See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/7.10/indices-delete-index.html.
func (*ESClient) DeleteIndices ¶
IndicesDelete deletes an index. See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/7.10/indices-delete-index.html.
func (*ESClient) GetIndices ¶
GetIndices returns information about one or more indices.
func (*ESClient) MultiSearch ¶
Msearch allows to execute several search operations in one request. See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/search-multi-search.html.
func (*ESClient) NewBulkIndexer ¶
NewBulkIndexer creates a bulkIndexer for use of the client.
func (*ESClient) Search ¶
Search returns results matching a query. See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html.
type HealthStatus ¶
type HealthStatus int
HealthStatus - iota enum of possible health states returned by Elasticsearch API
func (HealthStatus) String ¶
func (hs HealthStatus) String() string