elasticsearch

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2015 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotConnected indicates failure due to client having no valid connection
	ErrNotConnected = errors.New("not connected")

	// ErrJSONEncodeFailed indicates encoding failures
	ErrJSONEncodeFailed = errors.New("json encode failed")

	// ErrResponseRead indicates error parsing Elasticsearch response
	ErrResponseRead = errors.New("bulk item status parse failed.")
)

Functions

This section is empty.

Types

type BulkResult

type BulkResult struct {
	Items []json.RawMessage `json:"items"`
}

type Client

type Client struct {
	Connection
	// contains filtered or unexported fields
}

func NewClient

func NewClient(
	url, index string, tls *tls.Config,
	username, password string,
) *Client

func (*Client) Clone

func (client *Client) Clone() *Client

func (*Client) PublishEvent

func (client *Client) PublishEvent(event common.MapStr) error

func (*Client) PublishEvents

func (client *Client) PublishEvents(
	events []common.MapStr,
) ([]common.MapStr, error)

type Connection

type Connection struct {
	URL      string
	Username string
	Password string
	// contains filtered or unexported fields
}

func (*Connection) Bulk

func (conn *Connection) Bulk(
	index, docType string,
	params map[string]string, body []interface{},
) (*QueryResult, error)

Bulk performs many index/delete operations in a single API call. Implements: http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html

func (*Connection) BulkWith

func (conn *Connection) BulkWith(
	index string,
	docType string,
	params map[string]string,
	metaBuilder MetaBuilder,
	body []interface{},
) (*QueryResult, error)

BulkWith creates a HTTP request containing a bunch of operations and send them to Elasticsearch. The request is retransmitted up to max_retries before returning an error.

func (*Connection) Close

func (conn *Connection) Close() error

func (*Connection) Connect

func (conn *Connection) Connect(timeout time.Duration) error

func (*Connection) CountSearchURI

func (es *Connection) CountSearchURI(
	index string, docType string,
	params map[string]string,
) (int, *CountResults, error)

func (*Connection) CreateIndex

func (es *Connection) CreateIndex(index string, body interface{}) (int, *QueryResult, error)

CreateIndex creates a new index, optionally with settings and mappings passed in the body. Implements: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html

func (*Connection) Delete

func (es *Connection) Delete(index string, docType string, id string, params map[string]string) (int, *QueryResult, error)

Delete deletes a typed JSON document from a specific index based on its id. Implements: http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html

func (*Connection) Index

func (es *Connection) Index(
	index, docType, id string,
	params map[string]string,
	body interface{},
) (int, *QueryResult, error)

Index adds or updates a typed JSON document in a specified index, making it searchable. In case id is empty, a new id is created over a HTTP POST request. Otherwise, a HTTP PUT request is issued. Implements: http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html

func (*Connection) IsConnected

func (conn *Connection) IsConnected() bool

func (*Connection) Ping

func (conn *Connection) Ping(timeout time.Duration) (bool, error)

func (*Connection) Refresh

func (es *Connection) Refresh(index string) (int, *QueryResult, error)

Refresh an index. Call this after doing inserts or creating/deleting indexes in unit tests.

func (*Connection) SearchURI

func (es *Connection) SearchURI(index string, docType string, params map[string]string) (int, *SearchResults, error)

A search request can be executed purely using a URI by providing request parameters. Implements: http://www.elastic.co/guide/en/elasticsearch/reference/current/search-uri-request.html

type CountResults

type CountResults struct {
	Count  int             `json:"count"`
	Shards json.RawMessage `json:"_shards"`
}

type Hits

type Hits struct {
	Total int
	Hits  []json.RawMessage `json:"hits"`
}

type MetaBuilder

type MetaBuilder func(interface{}) interface{}

MetaBuilder creates meta data for bulk requests

type QueryResult

type QueryResult struct {
	Ok      bool            `json:"ok"`
	Index   string          `json:"_index"`
	Type    string          `json:"_type"`
	ID      string          `json:"_id"`
	Source  json.RawMessage `json:"_source"`
	Version int             `json:"_version"`
	Found   bool            `json:"found"`
	Exists  bool            `json:"exists"`
	Created bool            `json:"created"`
	Matches []string        `json:"matches"`
}

func (QueryResult) String

func (r QueryResult) String() string

type SearchResults

type SearchResults struct {
	Took   int                        `json:"took"`
	Shards json.RawMessage            `json:"_shards"`
	Hits   Hits                       `json:"hits"`
	Aggs   map[string]json.RawMessage `json:"aggregations"`
}

Jump to

Keyboard shortcuts

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