client

package
v1.2.15 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2025 License: MIT Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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