elasticsearch

package
Version: v1.0.0-beta4 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2015 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

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

type ConnectionPool

type ConnectionPool struct {
	Connections []*Connection

	// options
	DeadTimeout time.Duration
	// contains filtered or unexported fields
}

func (*ConnectionPool) GetConnection

func (pool *ConnectionPool) GetConnection() *Connection

GetConnection finds a live connection.

func (*ConnectionPool) MarkDead

func (pool *ConnectionPool) MarkDead(conn *Connection)

MarkDead marks a failed connection as dead and put on timeout. timeout = DeadTimeout * 2 ^ (deadCount - 1) When the timeout is over, the connection will be resurrected and returned to the live pool.

func (*ConnectionPool) MarkLive

func (pool *ConnectionPool) MarkLive(conn *Connection)

MarkLive marks a connection as live if the connection has been previously marked as dead and succeeds.

func (*ConnectionPool) SetConnections

func (pool *ConnectionPool) SetConnections(urls []string, username string, password string) error

func (*ConnectionPool) SetDeadTimeout

func (pool *ConnectionPool) SetDeadTimeout(timeout time.Duration)

type CountResults

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

type Elasticsearch

type Elasticsearch struct {
	MaxRetries int
	// contains filtered or unexported fields
}

func NewElasticsearch

func NewElasticsearch(
	urls []string,
	tls *tls.Config,
	username, password string,
) *Elasticsearch

NewElasticsearch creates a connection to Elasticsearch.

func (*Elasticsearch) Bulk

func (es *Elasticsearch) Bulk(index string, 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 (*Elasticsearch) BulkWith

func (es *Elasticsearch) 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 (*Elasticsearch) CountSearchURI

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

func (*Elasticsearch) CreateIndex

func (es *Elasticsearch) CreateIndex(index string, body interface{}) (*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 (*Elasticsearch) Delete

func (es *Elasticsearch) Delete(index string, docType string, id string, params map[string]string) (*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 (*Elasticsearch) Index

func (es *Elasticsearch) Index(index string, docType string, id string,
	params map[string]string, body interface{}) (*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 (*Elasticsearch) Refresh

func (es *Elasticsearch) Refresh(index string) (*QueryResult, error)

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

func (*Elasticsearch) SearchURI

func (es *Elasticsearch) SearchURI(index string, docType string, params map[string]string) (*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

func (*Elasticsearch) SetMaxRetries

func (es *Elasticsearch) SetMaxRetries(maxRetries int)

type Hits

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

type MetaBuilder

type MetaBuilder interface {
	Meta(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