elasticsearch

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitializeContext

func InitializeContext(ctx context.Context) context.Context

InitializeContext adds the elasticsearch session to the context. The new context is returned because context is immutable.

Types

type ContextKey

type ContextKey string

ContextKey defines a type to store the elasticsearch session in context.Context.

type IndexedDocument

type IndexedDocument struct {
	Index string `json:"_index"`
	Id    string `json:"_id"`
}

IndexedDocument represents an Elasticsearch response of an index request with indexed document information

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger logs the elasticsearch requests and responses in a configurable file.

func GetLogger

func GetLogger() *Logger

GetLogger returns the logger for elasticsearch requests and responses. If the logger is not created yet, it creates a new instance of Logger.

func NewLogger

func NewLogger(path string) (*Logger, error)

NewLogger creates an instance of the logger. It configures the file path where the elasticsearch requests and responses are written.

func (Logger) LogCreateIndex

func (l Logger) LogCreateIndex(res *esapi.Response, document, index, corr string)

LogCreateIndex logs a creation in elasticsearch in the configured log file.

func (Logger) LogError

func (l Logger) LogError(err error, corr string)

LogError logs a creation in elasticsearch in the configured log file.

func (Logger) LogSearchIndex

func (l Logger) LogSearchIndex(res *esapi.Response, body, index, corr string)

LogSearchIndex logs a search in elasticsearch in the configured log file.

type Response

type Response struct {
	Error ResponseError `json:"error"`
}

Response represents the body of an elasticsearch response

type ResponseError

type ResponseError struct {
	Type   string `json:"type"`
	Reason string `json:"reason"`
}

ResponseError represents the error information in elasticsearch response

type Session

type Session struct {
	Client       *elasticsearch.Client
	SearchResult golium.Map
	Correlator   string
	// contains filtered or unexported fields
}

Session contains the information of a elasticsearch session.

func GetSession

func GetSession(ctx context.Context) *Session

GetSession returns the elasticsearch session stored in context. Note that the context should be previously initialized with InitializeContext function.

func (*Session) CleanUp

func (s *Session) CleanUp(ctx context.Context)

CleanUp cleans session by deleting all indexed documents in Elasticsearch

func (*Session) ConfigureClient

func (s *Session) ConfigureClient(ctx context.Context, config elasticsearch.Config) error

ConfigureClient creates a elasticsearch connection based on the URI.

func (*Session) NewDocument

func (s *Session) NewDocument(ctx context.Context, index string, props map[string]interface{}) error

NewDocument creates a new document, with the given JSON and for the given index.

func (*Session) SearchDocument

func (s *Session) SearchDocument(ctx context.Context, index string, body string) error

SearchDocument searches in elasticsearch with given index and JSON body and saves the result in the application context.

func (*Session) ValidateDocumentJSONProperties

func (s *Session) ValidateDocumentJSONProperties(ctx context.Context, props map[string]interface{}) error

ValidateDocumentJSONProperties validates that the search result in the application context has the given properties.

type Steps

type Steps struct {
}

Steps type is responsible to initialize the Elasticsearch client steps in godog framework.

func (Steps) InitializeSteps

func (s Steps) InitializeSteps(ctx context.Context, scenCtx *godog.ScenarioContext) context.Context

InitializeSteps adds client elasticsearch steps to the scenario context. It implements StepsInitializer interface. It returns a new context (context is immutable) with the elasticsearch Context.

Jump to

Keyboard shortcuts

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