client

package
v1.2.13-prerelease12 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// ClearScroll clears the search context and results for a scrolling search.
	ClearScroll(ctx context.Context, scrollID string) error
	// Count returns number of document matches by given query
	Count(ctx context.Context, index, body string) (int64, error)
	// CreateIndex creates index with given name
	CreateIndex(ctx context.Context, index string) error
	// IsNotFoundError checks if error is a "not found"
	IsNotFoundError(err error) bool
	// PutMapping updates Client with new field mapping
	PutMapping(ctx context.Context, index, body string) error
	// RunBulkProcessor starts bulk indexing processor
	// @TODO consider to extract Bulk Processor as a separate entity
	RunBulkProcessor(ctx context.Context, p *bulk.BulkProcessorParameters) (bulk.GenericBulkProcessor, error)
	// Scroll retrieves the next batch of results for a scrolling search.
	Scroll(ctx context.Context, index, body, scrollID string) (*Response, error)
	// Search returns Elasticsearch hit bytes and additional metadata
	Search(ctx context.Context, index, body string) (*Response, error)
}

Client is a generic ES client implementation. This interface allows to use different Elasticsearch and OpenSearch versions without exposing implementation details and structs

type Response

type Response struct {
	TookInMillis int64
	TotalHits    int64
	Hits         *SearchHits
	Aggregations map[string]json.RawMessage
	Sort         []interface{}
	ScrollID     string
}

Response is used to pass data retrieved from Elasticsearch/OpenSearch to upper layer

type SearchHit

type SearchHit struct {
	Index  string          // index name
	ID     string          // external or internal
	Sort   []interface{}   // sort information
	Source json.RawMessage // stored document source
}

SearchHit is a single hit.

type SearchHits

type SearchHits struct {
	TotalHits *TotalHits   // total number of hits found
	Hits      []*SearchHit // the actual hits returned
}

SearchHits specifies the list of search hits.

type TotalHits

type TotalHits struct {
	Value int64 // value of the total hit count
}

TotalHits specifies total number of hits and its relation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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