elasticsearch

package
v1.0.0-beta3 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2015 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakePath

func MakePath(index string, doc_type string, id string) (string, error)

Create path out of index, doc_type and id that is used for querying Elasticsearch

func UrlEncode

func UrlEncode(params map[string]string) string

Encode parameters in url

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
	Dead_timeout time.Duration
	// contains filtered or unexported fields
}

func (*ConnectionPool) GetConnection

func (pool *ConnectionPool) GetConnection() *Connection

func (*ConnectionPool) MarkDead

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

If a connection fails, it will be marked as dead and put on timeout. timeout = default_timeout * 2 ** (fail_count - 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) error

A connection that has been previously marked as dead and succeeds will be marked as live and the dead_count is set to zero

func (*ConnectionPool) SelectRoundRobin

func (pool *ConnectionPool) SelectRoundRobin() *Connection

func (*ConnectionPool) SetConnections

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

func (*ConnectionPool) SetDeadTimeout

func (pool *ConnectionPool) SetDeadTimeout(timeout int)

type Elasticsearch

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

func NewElasticsearch

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

Create a connection to Elasticsearch

func (*Elasticsearch) Bulk

func (es *Elasticsearch) Bulk(index string, doc_type string,
	params map[string]string, body chan interface{}) (*QueryResult, error)

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

func (*Elasticsearch) BulkRequest

func (es *Elasticsearch) BulkRequest(method string, path string,
	params map[string]string, body chan interface{}) ([]byte, error)

Create 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) CreateIndex

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

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, doc_type string, id string, params map[string]string) (*QueryResult, error)

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, doc_type 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) PerformRequest

func (es *Elasticsearch) PerformRequest(conn *Connection, req *http.Request) ([]byte, bool, error)

Perform the actual request. If the operation was successful, mark it as live and return the response. Mark the Elasticsearch node as dead for a period of time in the case the http request fails with Connection Timeout, Connection Refused or returns one of the 503,504 Error Replies. It returns the response, if it should retry sending the request and the error

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) Request

func (es *Elasticsearch) Request(method string, path string,
	params map[string]string, body interface{}) ([]byte, error)

Create an HTTP request and send it to Elasticsearch. The request is retransmitted max_retries before returning an error.

func (*Elasticsearch) SearchUri

func (es *Elasticsearch) SearchUri(index string, doc_type 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(max_retries int)

type ElasticsearchOutput

type ElasticsearchOutput struct {
	Index          string
	TopologyExpire int
	Conn           *Elasticsearch
	FlushInterval  time.Duration
	BulkMaxSize    int

	TopologyMap map[string]string
	// contains filtered or unexported fields
}

func (*ElasticsearchOutput) EnableTTL

func (out *ElasticsearchOutput) EnableTTL() error

Enable using ttl as paramters in a server-ip doc type

func (*ElasticsearchOutput) GetNameByIP

func (out *ElasticsearchOutput) GetNameByIP(ip string) string

Get the name of a shipper by its IP address from the local topology map

func (*ElasticsearchOutput) Init

func (out *ElasticsearchOutput) Init(beat string, config outputs.MothershipConfig, topology_expire int) error

Initialize Elasticsearch as output

func (*ElasticsearchOutput) InsertBulkMessage

func (out *ElasticsearchOutput) InsertBulkMessage(bulkChannel chan interface{})

Insert a list of events in the bulkChannel

func (*ElasticsearchOutput) PublishEvent

func (out *ElasticsearchOutput) PublishEvent(ts time.Time, event common.MapStr) error

Publish an event by adding it to the queue of events.

func (*ElasticsearchOutput) PublishIPs

func (out *ElasticsearchOutput) PublishIPs(name string, localAddrs []string) error

Each shipper publishes a list of IPs together with its name to Elasticsearch

func (*ElasticsearchOutput) SendMessagesGoroutine

func (out *ElasticsearchOutput) SendMessagesGoroutine()

Goroutine that sends one or multiple events to Elasticsearch. If the flush_interval > 0, then the events are sent in batches. Otherwise, one by one.

func (*ElasticsearchOutput) UpdateLocalTopologyMap

func (out *ElasticsearchOutput) UpdateLocalTopologyMap()

Update the local topology map

type EventMsg

type EventMsg struct {
	Ts    time.Time
	Event common.MapStr
}

type Hits

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

type PublishedTopology

type PublishedTopology struct {
	Name string
	IPs  string
}

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 ReadQueryResult

func ReadQueryResult(obj []byte) (*QueryResult, error)

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"`
}

func ReadSearchResult

func ReadSearchResult(obj []byte) (*SearchResults, error)

Jump to

Keyboard shortcuts

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