aggregate

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	Key   string `json:"key"`
	Count uint64 `json:"count"`
}

Bucket represents a single term bucket and its count.

type CountByLevel

type CountByLevel string

CountByLevel is a typed string alias describing which document level the API should count by when aggregating. Values are defined by the backend. This type is intentionally open-ended to avoid breaking changes if the API adds new levels.

const (
	// CountByLevelHost counts at the host level.
	CountByLevelHost CountByLevel = "host"
	// CountByLevelService counts at the service level.
	CountByLevelService CountByLevel = "service"
	// CountByLevelProtocol counts at the protocol level.
	CountByLevelProtocol CountByLevel = "protocol"
)

type Params

type Params struct {
	OrgID         mo.Option[identifiers.OrganizationID]
	CollectionID  mo.Option[identifiers.CollectionID]
	Query         string
	Field         string
	NumBuckets    int64
	CountByLevel  mo.Option[CountByLevel]
	FilterByQuery mo.Option[bool]
}

AggregateParams bundles parameters used to perform an aggregation. Using a struct prevents parameter drift and improves readability as the API evolves.

Note: OrgID and CollectionID are options; only one of them is typically used at a time. If CollectionID is present, the aggregation occurs in the collection scope; otherwise, it occurs in the global scope. The CountByLevel option is a typed alias to reduce stringly-typed errors. The FilterByQuery option determines whether results are limited to values matching the query.

type Result

type Result struct {
	Meta    *responsemeta.ResponseMeta
	Buckets []Bucket
}

AggregateResult represents the normalized aggregation result returned by the application layer. It contains response metadata and a list of buckets.

type Service

type Service interface {
	// Aggregate performs an aggregation given the provided parameters.
	Aggregate(ctx context.Context, params Params) (Result, cenclierrors.CencliError)
}

Service is the search service for the aggregate command.

func New

func New(client client.Client) Service

Jump to

Keyboard shortcuts

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