elastic

package module
v0.0.0-...-36157cb Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2017 License: MIT Imports: 13 Imported by: 39

README

go-elastic

Little (incomplete) Elasticsearch client with AWS sigv4 support.

Badges

GoDoc


tjholowaychuk.com  ·  GitHub @tj  ·  Twitter @tjholowaychuk

Documentation

Overview

Package elastic provides an Elasticsearch client with AWS sigv4 support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AWSCredentials

type AWSCredentials awsauth.Credentials

AWSCredentials for AWS.

type BulkResponse

type BulkResponse struct {
	Took   float64             `json:"took"`
	Errors bool                `json:"errors"`
	Items  []*BulkResponseItem `json:"items"`
}

BulkResponse for _bulk.

type BulkResponseItem

type BulkResponseItem struct {
	Create *BulkResponseItemResult `json:"create,omitempty"`
	Delete *BulkResponseItemResult `json:"delete,omitempty"`
	Update *BulkResponseItemResult `json:"update,omitempty"`
	Index  *BulkResponseItemResult `json:"index,omitempty"`
}

BulkResponseItem for _bulk.

type BulkResponseItemResult

type BulkResponseItemResult struct {
	Index   string `json:"_index"`
	Type    string `json:"_type"`
	ID      string `json:"_id"`
	Version int    `json:"_version"`
	Status  int    `json:"status"`
	Found   bool   `json:"bool,omitempty"`
	Error   string `json:"error,omitempty"`
}

BulkResponseItem for _bulk request responses.

type Client

type Client struct {
	HTTPClient *http.Client

	URL string // URL to Elasticsearch cluster
	// contains filtered or unexported fields
}

Client is an Elasticsearch client.

func New

func New(url string) *Client

New client.

func (*Client) Aliases

func (c *Client) Aliases() (v aliases.Indexes, err error)

Aliases returns indexes and their aliases.

func (*Client) Bulk

func (c *Client) Bulk(body io.Reader) error

Bulk POST request with the given body.

func (*Client) BulkResponse

func (c *Client) BulkResponse(body io.Reader) (res *BulkResponse, err error)

BulkResponse POST request with the given body and return response.

func (*Client) DeleteAll

func (c *Client) DeleteAll() error

DeleteAll deletes all indexes.

func (*Client) DeleteIndex

func (c *Client) DeleteIndex(index string) error

DeleteIndex deletes `index`.

func (*Client) RefreshAll

func (c *Client) RefreshAll() error

RefreshAll refreshes all indexes.

func (*Client) RefreshIndex

func (c *Client) RefreshIndex(index string) error

RefreshIndex refreshes `index`.

func (*Client) RemoveOldAliases

func (c *Client) RemoveOldAliases(layout, alias string, n int, now time.Time) error

RemoveOldAliases removes `alias` from timeseries style indexes older than `n` days based on `layout` such as "logs-06-01-02". For example to maintain the past week (inclusive) you might use RemoveOldAliases("logs-06-01-02", "last_week", 8, time.Now()).

func (*Client) RemoveOldIndexes

func (c *Client) RemoveOldIndexes(layout string, n int, now time.Time) error

RemoveOldIndexes removes indexes from timeseries style indexes older than `n` days based on `layout` such as "logs-06-01-02". For example to maintain the past week (inclusive) you might use RemoveOldIndexes("logs-06-01-02", 8, time.Now()).

func (*Client) Request

func (c *Client) Request(method, path string, body io.Reader, v interface{}) error

Request performs a request against `url` storing the results as `v` when non-nil.

func (*Client) SearchIndex

func (c *Client) SearchIndex(index string, query interface{}, v interface{}) error

SearchIndex queries `index` and stores the results of `query` in `v`.

func (*Client) SearchIndexString

func (c *Client) SearchIndexString(index, query string, v interface{}) error

SearchIndexString queries `index` and stores the results of `query` in `v`.

func (*Client) SearchIndexTemplate

func (c *Client) SearchIndexTemplate(index, tmpl string, data interface{}, v interface{}) error

SearchIndexTemplate queries `index` with `tmpl` string and stores the results in `v`.

func (*Client) SetAWSCredentials

func (c *Client) SetAWSCredentials(credentials AWSCredentials)

SetAWSCredentials for connection to an AWS ElasticSearch instance

func (*Client) SetAuthCredentials

func (c *Client) SetAuthCredentials(username, password string)

SetAuthCredentials for a username/password connection

Directories

Path Synopsis
Package batch lets you buffer bulk documents for insert.
Package batch lets you buffer bulk documents for insert.

Jump to

Keyboard shortcuts

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