opensearch

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultFieldMappingConfig = logs.FieldMappingConfig{
	Message:   []string{"message"},
	Timestamp: []string{"@timestamp"},
	Severity:  []string{"log"},
}

Functions

This section is empty.

Types

type Backend

type Backend struct {
	Address  string        `json:"address"`
	Username *types.EnvVar `json:"username,omitempty"`
	Password *types.EnvVar `json:"password,omitempty"`
}

+kubebuilder:object:generate=true

func (*Backend) DeepCopy

func (in *Backend) DeepCopy() *Backend

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Backend.

func (*Backend) DeepCopyInto

func (in *Backend) DeepCopyInto(out *Backend)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type HitsInfo

type HitsInfo struct {
	Total    TotalHitsInfo `json:"total"`
	MaxScore float64       `json:"max_score"`
	Hits     []SearchHit   `json:"hits"`
}

func (*HitsInfo) NextPage

func (t *HitsInfo) NextPage(requestedRowsCount int) string

NextPage returns the next page token.

type RawClientMixin

type RawClientMixin interface {
	GetRawClient() any
}

type Request

type Request struct {
	Index string `json:"index" template:"true"`
	Query string `json:"query" template:"true"`
	Limit string `json:"limit,omitempty" template:"true"`
}

+kubebuilder:object:generate=true

func (*Request) DeepCopy

func (in *Request) DeepCopy() *Request

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Request.

func (*Request) DeepCopyInto

func (in *Request) DeepCopyInto(out *Request)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Response

type Response struct {
	Took     float64  `json:"took"`
	TimedOut bool     `json:"timed_out"`
	Hits     HitsInfo `json:"hits"`
	ScrollID string   `json:"_scroll_id,omitempty"`
}

type Result

type Result struct {
	// Id is the unique identifier provided by the underlying system, use to link to a point in time of a log stream
	Id string `json:"id,omitempty"`
	// RFC3339 timestamp
	Time    string            `json:"timestamp,omitempty"`
	Message string            `json:"message,omitempty"`
	Labels  map[string]string `json:"labels,omitempty"`
}

type ScrollOptions

type ScrollOptions struct {
	// Size is the number of documents to fetch per scroll request
	Size int `json:"size,omitempty"`
	// Timeout is how long to keep the scroll context alive
	Timeout time.Duration `json:"timeout,omitempty"`
	// Enabled determines if scroll should be used automatically for large result sets
	Enabled bool `json:"enabled,omitempty"`
}

ScrollOptions contains configuration for scroll operations

type ScrollRequest

type ScrollRequest struct {
	Request
	Scroll ScrollOptions `json:"scroll,omitempty"`
}

ScrollRequest extends Request with scroll-specific options

type SearchHit

type SearchHit struct {
	Index  string         `json:"_index"`
	Type   string         `json:"_type"`
	ID     string         `json:"_id"`
	Score  float64        `json:"_score"`
	Sort   []any          `json:"sort"`
	Source map[string]any `json:"_source"`
}

type SearchResults

type SearchResults struct {
	Total    int64            `json:"total,omitempty"`
	Results  []map[string]any `json:"results,omitempty"`
	NextPage string           `json:"nextPage,omitempty"`
}

type Searcher

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

func New

func New(ctx context.Context, backend Backend, mappingConfig *logs.FieldMappingConfig) (*Searcher, error)

func (*Searcher) ClearScroll

func (t *Searcher) ClearScroll(ctx context.Context, scrollID string) error

ClearScroll cleans up the scroll context

func (*Searcher) GetRawClient

func (t *Searcher) GetRawClient() *opensearch.Client

func (*Searcher) ScrollNext

func (t *Searcher) ScrollNext(ctx context.Context, scrollID string, scrollTimeout time.Duration) (*logs.LogResult, string, error)

ScrollNext retrieves the next batch of results using the scroll ID

func (*Searcher) Search

func (t *Searcher) Search(ctx context.Context, q Request) (*logs.LogResult, error)

func (*Searcher) SearchWithScroll

func (t *Searcher) SearchWithScroll(ctx context.Context, req ScrollRequest) (*logs.LogResult, string, error)

SearchWithScroll initiates a scroll search for large result sets

type TotalHitsInfo

type TotalHitsInfo struct {
	Value    int64  `json:"value"`
	Relation string `json:"relation"`
}

Jump to

Keyboard shortcuts

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