Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- func (cli *Client) AddDocument(ctx context.Context, indexName, documentID string, document []byte, ...) error
- func (cli *Client) BulkIndexAdd(ctx context.Context, action client.BulkIndexerAction, index, documentID string, ...) error
- func (cli *Client) BulkIndexClose(context.Context) error
- func (cli *Client) BulkUpdate(ctx context.Context, esDestIndex, esDestURL string, bulk []byte) ([]byte, error)
- func (cli *Client) Checker(ctx context.Context, state *health.CheckState) error
- func (cli *Client) CountIndices(ctx context.Context, indices []string) ([]byte, error)
- func (cli *Client) CreateIndex(ctx context.Context, indexName string, indexSettings []byte) error
- func (cli *Client) DeleteIndex(ctx context.Context, indexName string) error
- func (cli *Client) DeleteIndices(ctx context.Context, indices []string) error
- func (cli *Client) GetAlias(ctx context.Context) ([]byte, error)
- func (cli *Client) GetIndices(ctx context.Context, indexPatterns []string) (body []byte, err error)
- func (cli *Client) MultiSearch(ctx context.Context, searches []client.Search) ([]byte, error)
- func (cli *Client) NewBulkIndexer(ctx context.Context) error
- func (cli *Client) Search(ctx context.Context, search client.Search) ([]byte, error)
- func (cli *Client) UpdateAliases(ctx context.Context, alias string, addIndices, removeIndices []string) error
- type ClusterHealth
- type HealthStatus
Constants ¶
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
const (
ServiceName = "elasticsearch"
)
ServiceName elasticsearch
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 Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an ElasticSearch client containing an HTTP client to contact the elasticsearch API.
func NewClient ¶
NewClient returns a new initialised elasticsearch client with the default dp-net/http client
func NewClientWithHTTPClient ¶
func (*Client) AddDocument ¶
func (cli *Client) AddDocument(ctx context.Context, indexName, documentID string, document []byte, options *client.AddDocumentOptions) error
AddDocument adds a JSON document to elasticsearch
func (*Client) BulkIndexAdd ¶
func (*Client) BulkIndexClose ¶
Close waits until all added items are flushed and closes the indexer.
func (*Client) BulkUpdate ¶
func (cli *Client) BulkUpdate(ctx context.Context, esDestIndex, esDestURL string, bulk []byte) ([]byte, error)
BulkUpdate uses an HTTP post request to submit data to Elastic Search
func (*Client) Checker ¶
Checker checks health of Elasticsearch, if the required indexes exist and updates the provided CheckState accordingly.
func (*Client) CountIndices ¶
CountIndices feature is not supported for ES version 2.
func (*Client) CreateIndex ¶
CreateIndex creates an index in elasticsearch
func (*Client) DeleteIndex ¶
DeleteIndex deletes an index in elasticsearch
func (*Client) DeleteIndices ¶
func (*Client) GetIndices ¶
GetIndices gets an index from elasticsearch
func (*Client) MultiSearch ¶
type ClusterHealth ¶
type ClusterHealth struct {
Status string `json:"status"`
}
ClusterHealth represents the response from the elasticsearch cluster health check
type HealthStatus ¶
type HealthStatus int
HealthStatus - iota enum of possible health states returned by Elasticsearch API
func (HealthStatus) String ¶
func (hs HealthStatus) String() string