v710

package
v4.0.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Create = client.BulkIndexerAction("create")
	Delete = client.BulkIndexerAction("delete")
	Index  = client.BulkIndexerAction("index")
	Update = client.BulkIndexerAction("update")
)
View Source
const (
	HealthGreen = iota
	HealthYellow
	HealthRed
)

Possible values for the HealthStatus

View Source
const MsgHealthy = "elasticsearch is healthy and the required indexes exist"

MsgHealthy Check message returned when elasticsearch is healthy and the required indexes exist

Variables

View Source
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

func (cli *ESClient) BulkIndexClose(ctx context.Context) error

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

func (cli *ESClient) Checker(ctx context.Context, state *health.CheckState) error

Checker checks health of Elasticsearch, if the required indexes exist and updates the provided CheckState accordingly.

func (*ESClient) CountIndices

func (cli *ESClient) CountIndices(ctx context.Context, indices []string) ([]byte, error)

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

func (cli *ESClient) CreateIndex(ctx context.Context, indexName string, indexSettings []byte) error

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

func (cli *ESClient) DeleteIndex(ctx context.Context, indexName string) error

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

func (cli *ESClient) DeleteIndices(ctx context.Context, indices []string) error

IndicesDelete deletes an index. See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/7.10/indices-delete-index.html.

func (*ESClient) GetAlias

func (cli *ESClient) GetAlias(ctx context.Context) ([]byte, error)

GetAlias returns a list of indices.

func (*ESClient) GetIndices

func (cli *ESClient) GetIndices(ctx context.Context, indexPatterns []string) ([]byte, error)

GetIndices returns information about one or more indices.

func (*ESClient) MultiSearch

func (cli *ESClient) MultiSearch(ctx context.Context, searches []client.Search, queryParams *client.QueryParams) ([]byte, error)

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

func (cli *ESClient) NewBulkIndexer(ctx context.Context) error

NewBulkIndexer creates a bulkIndexer for use of the client.

func (*ESClient) Search

func (cli *ESClient) Search(ctx context.Context, search client.Search) ([]byte, error)

Search returns results matching a query. See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html.

func (*ESClient) UpdateAliases

func (cli *ESClient) UpdateAliases(ctx context.Context, alias string, removeIndices, addIndices []string) error

UpdateAliases removes and adds an alias to indexes.

type HealthStatus

type HealthStatus int

HealthStatus - iota enum of possible health states returned by Elasticsearch API

func (HealthStatus) String

func (hs HealthStatus) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL