opensearchinspect

package
v0.1.31 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package opensearchinspect provides bounded, read-only OpenSearch metadata inspection.

Index

Constants

View Source
const (
	DefaultMaxTargets = 2000
	DefaultMaxFields  = 20000
)
View Source
const (
	ContainerObject     = "object"
	ContainerNested     = "nested"
	ContainerFlatObject = "flat_object"
)

Container mapping types. A field's ancestor is reduced to one of these, or to the empty string when the field sits at the root of the document.

Variables

This section is empty.

Functions

func TimestampedPattern added in v0.1.29

func TimestampedPattern(name string) (string, bool)

TimestampedPattern reports the wildcard a rotated index rolls up into, and whether the name looked rotated at all.

Types

type Field

type Field struct {
	Name         string   `json:"name"`
	Types        []string `json:"types"`
	Searchable   bool     `json:"searchable"`
	Aggregatable bool     `json:"aggregatable"`
	Conflicting  bool     `json:"conflicting,omitempty"`
	Format       string   `json:"format,omitempty"`
	// FormatConflicting reports that indices behind the target map this field
	// with different date formats.
	FormatConflicting bool `json:"formatConflicting,omitempty"`

	// Container names the innermost object, nested or flat_object ancestor this
	// field sits inside, and ContainerType is how that ancestor is mapped.
	//
	// They are carried down because the leaf alone cannot say how a selection on
	// it behaves: `_field_caps` reports the key of a `nested` tag list and the key
	// of a plain array of objects identically — both `keyword`, both searchable,
	// both aggregatable — and the two need opposite treatment. Only the ancestor's
	// own entry distinguishes them.
	Container     string `json:"container,omitempty"`
	ContainerType string `json:"containerType,omitempty"`
}

func (Field) Nested added in v0.1.29

func (f Field) Nested() bool

Nested reports that a selection on this field must be compiled inside a nested query to mean anything: OpenSearch indexes each element of a `nested` field as its own document, so a flat clause on `tags.key` matches no parent document at all — silently, with no error to read.

type FieldCatalog

type FieldCatalog struct {
	Target         Target                    `json:"target"`
	Fields         []Field                   `json:"fields"`
	Truncated      bool                      `json:"truncated,omitempty"`
	TruncateReason string                    `json:"truncateReason,omitempty"`
	Cache          *inspection.CacheMetadata `json:"cache,omitempty"`
}

type FieldRequest added in v0.1.29

type FieldRequest struct {
	Target         Target
	Names          []string
	IncludeFormats bool
	Refresh        bool
}

FieldRequest selects one target and optionally narrows its field catalog.

type Inspector

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

func New

func New(client *opensearch.Client, options Options) (*Inspector, error)

func (*Inspector) Fields

func (i *Inspector) Fields(ctx context.Context, request FieldRequest) (FieldCatalog, error)

func (*Inspector) Targets

func (i *Inspector) Targets(ctx context.Context, request TargetRequest) (TargetCatalog, error)

type Options

type Options struct {
	MaxTargets int
	MaxFields  int
	CacheKey   string
}

type Target

type Target struct {
	Name       string `json:"name"`
	Kind       string `json:"kind"`
	Hidden     bool   `json:"hidden,omitempty"`
	System     bool   `json:"system,omitempty"`
	DataStream string `json:"dataStream,omitempty"`
	// Pattern names the wildcard target a rotated index rolls up into.
	Pattern string `json:"pattern,omitempty"`
	// Count is how many rotations a `pattern` target covers.
	Count   int      `json:"count,omitempty"`
	Members []string `json:"members,omitempty"`
}

func RollupTargets added in v0.1.29

func RollupTargets(targets []Target) []Target

RollupTargets folds rotations of the same index into one wildcard target, so an author picks `jaeger-span-*` once instead of scrolling fifty-three daily indexes. A pattern is only synthesised for two or more rotations — a lone dated index is already its own best name — and data-stream backing indices are left alone, because the data stream already names them.

func (Target) QueryName added in v0.1.29

func (t Target) QueryName() string

type TargetCatalog

type TargetCatalog struct {
	Targets        []Target                  `json:"targets"`
	Truncated      bool                      `json:"truncated,omitempty"`
	TruncateReason string                    `json:"truncateReason,omitempty"`
	Cache          *inspection.CacheMetadata `json:"cache,omitempty"`
}

type TargetRequest added in v0.1.29

type TargetRequest struct {
	Refresh bool
}

Jump to

Keyboard shortcuts

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