elasticsearch

package
v0.0.0-...-b4bb62b Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBadConfig error bad configuration file
	ErrBadConfig = func(reason string) error { return fmt.Errorf("Config file is misconfigured: %s", reason) }
	// ErrIndexTypeNotFound error index type used but not defined
	ErrIndexTypeNotFound = errors.New("Index type not found in the indices map")
)
View Source
var (
	// RollingRate delay between two potential rolling index
	RollingRate = time.Minute
)

Functions

func FormatFilter

func FormatFilter(filter *filters.Filter, normalizeKey func(string) string) elastic.Query

FormatFilter creates a ElasticSearch request based on filters

func SetRollingRate

func SetRollingRate(rate time.Duration)

SetRollingRate override the default rolling index rate. Has to be called before client instantiation.

Types

type Client

type Client struct {
	sync.RWMutex
	Config Config
	// contains filtered or unexported fields
}

Client describes a ElasticSearch client connection

func NewClient

func NewClient(indices []Index, cfg Config, electionService etcd.MasterElectionService) (*Client, error)

NewClient creates a new ElasticSearch client based on configuration

func (*Client) AddEventListener

func (c *Client) AddEventListener(listener storage.EventListener)

AddEventListener add event listener

func (*Client) BulkDelete

func (c *Client) BulkDelete(index Index, id string) error

BulkDelete an object with the indexer

func (*Client) BulkIndex

func (c *Client) BulkIndex(index Index, id string, data interface{}) error

BulkIndex returns the bulk index from the indexer

func (*Client) Delete

func (c *Client) Delete(index Index, id string) (*elastic.DeleteResponse, error)

Delete an object

func (*Client) Get

func (c *Client) Get(index Index, id string) (*elastic.GetResult, error)

Get an object

func (*Client) GetClient

func (c *Client) GetClient() *elastic.Client

GetClient returns the elastic client object

func (*Client) Index

func (c *Client) Index(index Index, id string, data interface{}) error

Index returns the skydive index

func (*Client) Scroll

func (c *Client) Scroll(hits chan<- *elastic.SearchHit, query elastic.Query, opts filters.SearchQuery, indices ...string) error

Scroll objects using the Scroll API. Send all hits to the hits channel. Sort options are ignored, they impose a big performace hit.

func (*Client) Search

func (c *Client) Search(query elastic.Query, opts filters.SearchQuery, indices ...string) (*elastic.SearchResult, error)

Search an object. Maximum 10000 hits

func (*Client) Start

func (c *Client) Start()

Start the Elasticsearch client background jobs

func (*Client) Started

func (c *Client) Started() bool

Started is the client already started ?

func (*Client) Stop

func (c *Client) Stop()

Stop Elasticsearch background client

func (*Client) UpdateByScript

func (c *Client) UpdateByScript(query elastic.Query, script *elastic.Script, indices ...string) error

UpdateByScript updates the document using the given script

type ClientInterface

type ClientInterface interface {
	Index(index Index, id string, data interface{}) error
	BulkIndex(index Index, id string, data interface{}) error
	Get(index Index, id string) (*elastic.GetResult, error)
	Delete(index Index, id string) (*elastic.DeleteResponse, error)
	BulkDelete(index Index, id string) error
	Search(query elastic.Query, pagination filters.SearchQuery, indices ...string) (*elastic.SearchResult, error)
	Scroll(hits chan<- *elastic.SearchHit, query elastic.Query, pagination filters.SearchQuery, indices ...string) error
	Start()
	AddEventListener(listener storage.EventListener)
	UpdateByScript(query elastic.Query, script *elastic.Script, indices ...string) error
}

ClientInterface describes the mechanism API of ElasticSearch database client

type Config

type Config struct {
	ElasticHosts       []string
	InsecureSkipVerify bool
	Username           string
	Password           string
	BulkMaxDelay       int
	TotalFieldsLimit   int
	EntriesLimit       int
	AgeLimit           int
	IndicesLimit       int
	NoSniffing         bool
	IndexPrefix        string
	SniffingScheme     string
	NoHealthcheck      bool
	Debug              bool
}

Config describes configuration for elasticsearch

type ErrorLogger

type ErrorLogger struct{}

ErrorLogger implements the oliviere/elastic Logger interface to be used with error mesages

func (ErrorLogger) Printf

func (l ErrorLogger) Printf(format string, v ...interface{})

Printf sends elastic error messages to skydive logger Error

type Index

type Index struct {
	Name      string
	Mapping   string
	RollIndex bool
	URL       string
}

Index defines a Client Index

func (*Index) Alias

func (i *Index) Alias(prefix string) string

Alias returns the Alias of the index

func (*Index) FullName

func (i *Index) FullName(prefix string) string

FullName returns the full name of an index, prefix, name, version, suffix in case of rolling index

func (*Index) IndexWildcard

func (i *Index) IndexWildcard(prefix string) string

IndexWildcard returns the Index wildcard search string used to all the indexes of an index definition. Useful to request rolled over indexes.

type InfoLogger

type InfoLogger struct{}

InfoLogger implements the oliviere/elastic Logger interface to be used with info messages

func (InfoLogger) Printf

func (l InfoLogger) Printf(format string, v ...interface{})

Printf sends elastic info messages to skydive logger Info

type TraceLogger

type TraceLogger struct{}

TraceLogger implements the oliviere/elastic Logger interface to be used with trace messages

func (TraceLogger) Printf

func (l TraceLogger) Printf(format string, v ...interface{})

Printf sends elastic trace messages to skydive logger Debug

Jump to

Keyboard shortcuts

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