elasticsearch

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package elasticsearch provides Elasticsearch search client helpers.

New code should use the core-owned search boundary:

import "github.com/InsideGallery/core/db/elasticsearch"

client, err := elasticsearch.NewSearchClient(elasticsearch.Options{
	Addresses: []string{"http://localhost:9200"},
})

Use Searcher, SearchOptions, and SearchResult for consumer-facing code that should not expose Elasticsearch SDK request or response types.

Compatibility: Client and NewClient remain available for existing SDK-shaped callers. Prefer NewSearchClient for new integrations.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWrongResponse         = errors.New("wrong response")
	ErrWrongCountOfArguments = errors.New("error count of arguments")
)

Functions

This section is empty.

Types

type Client deprecated

type Client struct {
	*elasticsearch.Client
}

Client is the legacy Elasticsearch SDK-shaped client.

Deprecated: use SearchClient and core-owned option/result types for new code.

func NewClient deprecated

func NewClient() (*Client, error)

NewClient creates the legacy Elasticsearch SDK-shaped client.

Deprecated: use NewSearchClient for new code.

func (*Client) GetMatchQuery

func (c *Client) GetMatchQuery(keyValues ...string) (map[string]interface{}, error)

func (*Client) SearchByIndex

func (c *Client) SearchByIndex(
	ctx context.Context,
	indexes []string,
	query map[string]interface{},
) (map[string]interface{}, error)

type Options added in v1.1.0

type Options struct {
	Addresses []string
	Username  string
	Password  string
	CloudID   string
	APIKey    string
}

Options is the core-owned input for creating an Elasticsearch search client.

type SearchClient added in v1.1.0

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

SearchClient wraps the Elasticsearch SDK behind core-owned inputs and results.

func NewSearchClient added in v1.1.0

func NewSearchClient(options Options) (*SearchClient, error)

NewSearchClient creates an Elasticsearch search client from core-owned options.

func (*SearchClient) Search added in v1.1.0

func (c *SearchClient) Search(ctx context.Context, options SearchOptions) (SearchResult, error)

Search searches indexes through core-owned inputs and results.

type SearchOptions added in v1.1.0

type SearchOptions struct {
	Indexes []string
	Query   map[string]any
}

SearchOptions is the core-owned input for an Elasticsearch search.

type SearchResult added in v1.1.0

type SearchResult struct {
	Body map[string]any
}

SearchResult is the core-owned search result.

type Searcher added in v1.1.0

type Searcher interface {
	Search(ctx context.Context, options SearchOptions) (SearchResult, error)
}

Searcher is the core-owned Elasticsearch contract for new consumers.

Jump to

Keyboard shortcuts

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