opensearch

package
v0.4.23 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSearcher

func NewSearcher(ctx context.Context, config Config) (port.ResourceSearcher, error)

NewSearcher returns a new OpenSearchSearcher implementation

Types

type AggregationBucket added in v0.4.5

type AggregationBucket struct {
	Key      string `json:"key"`
	DocCount uint64 `json:"doc_count"`
}

AggregationBucket represents a single aggregation bucket.

type AggregationResponse added in v0.4.5

type AggregationResponse struct {
	GroupBy TermsAggregation `json:"group_by"`
}

AggregationResponse represents the aggregations in a search response.

type Config

type Config struct {
	URL   string `json:"url"`
	Index string `json:"index"`
}

Config represents OpenSearch configuration

type CountResponse added in v0.4.5

type CountResponse struct {
	Count int `json:"count"`
}

type Hit

type Hit struct {
	ID     string          `json:"_id"`
	Score  float64         `json:"_score"`
	Source json.RawMessage `json:"_source"`
}

Hit represents a single search result hit

type Hits

type Hits struct {
	Total `json:"total"`
	Hits  []Hit `json:"hits"`
}

Hits represents the hits in the search response

type OpenSearchClientRetriever

type OpenSearchClientRetriever interface {
	Search(ctx context.Context, index string, query []byte, pageSize int) (*SearchResponse, error)
	Count(ctx context.Context, index string, query []byte) (*CountResponse, error)
	AggregationSearch(ctx context.Context, index string, query []byte) (*AggregationResponse, error)
	IsReady(ctx context.Context) error
}

OpenSearchClientRetriever defines the interface for OpenSearch operations This allows for easy mocking and testing

type OpenSearchSearcher

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

OpenSearchSearcher implements the ResourceSearcher interface for OpenSearch

func (*OpenSearchSearcher) IsReady

func (o *OpenSearchSearcher) IsReady(ctx context.Context) error

func (*OpenSearchSearcher) QueryResources

func (os *OpenSearchSearcher) QueryResources(ctx context.Context, criteria model.SearchCriteria) (*model.SearchResult, error)

QueryResources implements the ResourceSearcher interface

func (*OpenSearchSearcher) QueryResourcesCount added in v0.4.5

func (os *OpenSearchSearcher) QueryResourcesCount(
	ctx context.Context,
	publicCountCriteria model.SearchCriteria,
	aggregationCriteria model.SearchCriteria,
	publicOnly bool,
) (*model.CountResult, error)

func (*OpenSearchSearcher) Render

func (os *OpenSearchSearcher) Render(ctx context.Context, criteria model.SearchCriteria) ([]byte, error)

Render generates the OpenSearch query based on the provided search criteria

type SearchResponse

type SearchResponse struct {
	Hits      `json:"hits"`
	PageToken *string `json:"last_item_id,omitempty"`
}

SearchResponse represents the OpenSearch search response

type TermsAggregation added in v0.4.5

type TermsAggregation struct {
	DocCountErrorUpperBound uint64              `json:"doc_count_error_upper_bound"`
	SumOtherDocCount        uint64              `json:"sum_other_doc_count"`
	Buckets                 []AggregationBucket `json:"buckets"`
}

TermsAggregation represents a terms aggregation response.

type Total

type Total struct {
	Value int `json:"value"`
}

Total represents the total number of hits

Jump to

Keyboard shortcuts

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