elasticsearch

package
v1.20.1 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Elasticsearch

type Elasticsearch struct {
	*elasticsearch.Client
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) *Elasticsearch

func (*Elasticsearch) Init

func (es *Elasticsearch) Init(opts ...Option) error

func (*Elasticsearch) Provide

func (es *Elasticsearch) Provide(ctx context.Context) interface{}

type Hits

type Hits struct {
	Total    *Total     `json:"total"`
	MaxScore float64    `json:"max_score"`
	Hits     []*SubHits `json:"hits"`
}

type Option

type Option func(*Options)

func WithAddresses

func WithAddresses(addresses []string) Option

func WithApiKey

func WithApiKey(apiKey string) Option

func WithCACert

func WithCACert(caCert string) Option

func WithCertificateFingerprint

func WithCertificateFingerprint(certificateFingerprint string) Option

func WithCloudID

func WithCloudID(cloudId string) Option

func WithCompressRequestBody

func WithCompressRequestBody(compressRequestBody bool) Option

func WithDisableMetaHeader

func WithDisableMetaHeader(disableMetaHeader bool) Option

func WithDisableRetry

func WithDisableRetry(disableRetry bool) Option

func WithDiscoverNodesInterval

func WithDiscoverNodesInterval(discoverNodesInterval time.Duration) Option

func WithDiscoverNodesOnStart

func WithDiscoverNodesOnStart(discoverNodesOnStart bool) Option

func WithEnableCompatibilityMode

func WithEnableCompatibilityMode(enableCompatibilityMode bool) Option

func WithEnableDebugLogger

func WithEnableDebugLogger(enableDebugLogger bool) Option

func WithEnableMetrics

func WithEnableMetrics(enableMetrics bool) Option

func WithHeader

func WithHeader(header map[string][]string) Option

func WithMaxRetries

func WithMaxRetries(maxRetries int) Option

func WithPassword

func WithPassword(password string) Option

func WithRetryOnStatus

func WithRetryOnStatus(retryOnStatus []int) Option

func WithServiceToken

func WithServiceToken(serviceToken string) Option

func WithUsername

func WithUsername(username string) Option

type Options

type Options struct {
	Addresses []string // A list of Elasticsearch nodes to use.
	Username  string   // Username for HTTP Basic Authentication.
	Password  string   // Password for HTTP Basic Authentication.

	CloudID                string // Endpoint for the Elastic Service (https://elastic.co/cloud).
	APIKey                 string // Base64-encoded token for authorization; if set, overrides username/password and service token.
	ServiceToken           string // Service token for authorization; if set, overrides username/password.
	CertificateFingerprint string // SHA256 hex fingerprint given by Elasticsearch on first launch.

	Header http.Header // Global HTTP request header.

	// PEM-encoded certificate authorities.
	// When set, an empty certificate pool will be created, and the certificates will be appended to it.
	// The option is only valid when the transport is not specified, or when it's http.Transport.
	CACert string

	RetryOnStatus []int                           // List of status codes for retry. Default: 502, 503, 504.
	DisableRetry  bool                            // Default: false.
	MaxRetries    int                             // Default: 3.
	RetryOnError  func(*http.Request, error) bool // Optional function allowing to indicate which error should be retried. Default: nil.

	CompressRequestBody bool // Default: false.

	DiscoverNodesOnStart  bool          // Discover nodes when initializing the client. Default: false.
	DiscoverNodesInterval time.Duration // Discover nodes periodically. Default: disabled.

	EnableMetrics           bool // Enable the metrics collection.
	EnableDebugLogger       bool // Enable the debug logging.
	EnableCompatibilityMode bool // Enable sends compatibility header

	DisableMetaHeader bool // Disable the additional "X-Elastic-Client-Meta" HTTP header.
}

type QueryResponse

type QueryResponse struct {
	Took         int                    `json:"took"`
	TimeOut      bool                   `json:"time_out"`
	Shards       *Shards                `json:"_shards"`
	Hits         *Hits                  `json:"hits"`
	Aggregations map[string]interface{} `json:"aggregations"`
}

type Shards

type Shards struct {
	Total      int `json:"total"`
	Successful int `json:"successful"`
	Skipped    int `json:"skipped"`
	Failed     int `json:"failed"`
}

type SubHits

type SubHits struct {
	Index  string                 `json:"_index"`
	Type   string                 `json:"_type"`
	Id     string                 `json:"_id"`
	Score  float64                `json:"_score"`
	Source map[string]interface{} `json:"_source"`
}

type Total

type Total struct {
	Value    int64  `json:"value"`
	Relation string `json:"relation"`
}

Jump to

Keyboard shortcuts

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