import "github.com/greenbone/opensight-golang-libraries/pkg/openSearch/esextension"Package esextensions provides extensions for https://github.com/aquasecurity/esquery
- type CompositeAgg
- func Composite(name string) *CompositeAgg
- func (agg *CompositeAgg) After(after map[string]string) *CompositeAgg
- func (agg *CompositeAgg) Aggregations(aggregations ...esquery.Aggregation) *CompositeAgg
- func (agg *CompositeAgg) Map() map[string]interface{}
- func (agg *CompositeAgg) Name() string
- func (agg *CompositeAgg) Size(size uint64) *CompositeAgg
- func (agg *CompositeAgg) Sources(sources ...esquery.Mappable) *CompositeAgg
- type MatchQuery
- type NestedQuery
- type ScriptedMetricAggregation
- type ScriptedSumAggregation
- type TermsSource
CompositeAgg represents a composite aggregation, as described in https://www.elastic.co/guide/en/elasticsearch/reference/7.17/search-aggregations-bucket-composite-aggregation.html . To be used in conjunction with the esquery library https://github.com/aquasecurity/esquery
type CompositeAgg struct {
// contains filtered or unexported fields
}func Composite(name string) *CompositeAggComposite creates an aggregation of type "composite".
func (agg *CompositeAgg) After(after map[string]string) *CompositeAggAfter sets the identification for the entry after which the next results should be returned.
func (agg *CompositeAgg) Aggregations(aggregations ...esquery.Aggregation) *CompositeAggAggregations sets the aggregations to be used for the buckets.
func (agg *CompositeAgg) Map() map[string]interface{}Map returns a map representation of the CompositeAgg, thus implementing the esquery.Mappable interface. Used for serialization to JSON.
func (agg *CompositeAgg) Name() stringName returns the name of the aggregation, needed for the esquery.Aggregation interface.
func (agg *CompositeAgg) Size(size uint64) *CompositeAggSize sets the maximum number of buckets to return.
func (agg *CompositeAgg) Sources(sources ...esquery.Mappable) *CompositeAggSources sets the sources for the buckets.
MatchQuery represents an OpenSearch match part in an OpenSearch query as described in https://www.elastic.co/guide/en/elasticsearch/reference/7.17/query-filter-context.html#query-filter-context-ex
type MatchQuery struct {
Field string
Value interface{}
}func Match(field string, value interface{}) *MatchQueryMatch creates a new MatchQuery.
func (mq *MatchQuery) Map() map[string]interface{}Map returns a map representation of the MatchQuery, thus implementing the esquery.Mappable interface. Used for serialization to JSON.
NestedQuery represents an OpenSearch nested query.
type NestedQuery struct {
Path string `json:"path"`
Query esquery.BoolQuery `json:"query"`
}func Nested(field string, q esquery.BoolQuery) *NestedQueryNested creates a new NestedQuery.
func (nq *NestedQuery) Map() map[string]interface{}Map returns a map representation of the NestedQuery, thus implementing the esquery.Mappable interface. Used for serialization to JSON.
ScriptedMetricAggregation represents a scripted_metric aggregation for Elasticsearch.
type ScriptedMetricAggregation struct {
// contains filtered or unexported fields
}func NewScriptedMetricAggregation(name string, initScript string, mapScript string, combineScript string, reduceScript string) *ScriptedMetricAggregationScriptedMetricAgg is a function that creates a new instance of ScriptedMetricAggregation. It takes the name, init script, map script, combine script, and reduce script as parameters and returns a pointer to the ScriptedMetricAggregation struct.
Example usage:
a := NewScriptedMetricAggregation("unique_asset_ids", initScript, mapScript, combineScript, reduceScript)
func (a *ScriptedMetricAggregation) Map() map[string]interface{}Map returns a map representation of the ScriptedMetricAggregation, thus implementing the esquery.Mappable interface. Used for serialization to JSON.
func (a *ScriptedMetricAggregation) Name() stringName returns the name of the ScriptedMetricAggregation, needed for the esquery.Aggregation interface.
ScriptedSumAggregation represents an aggregation that calculates the sum using a scripted expression. See https://www.elastic.co/guide/en/elasticsearch/reference/7.17/search-aggregations-metrics-sum-aggregation.html#_script_14 . To be used in conjunction with the esquery library https://github.com/aquasecurity/esquery
type ScriptedSumAggregation struct {
// contains filtered or unexported fields
}func ScriptedSumAgg(name string, script string) *ScriptedSumAggregationScriptedSumAgg is a function that creates a new instance of ScriptedSumAggregation. It takes the name and script as parameters and returns a pointer to the ScriptedSumAggregation struct. Example usage:
a := ScriptedSumAgg("testName", "testScript")
func (a *ScriptedSumAggregation) Map() map[string]interface{}Map returns a map representation of the ScriptedSumAggregation, thus implementing the esquery.Mappable interface. Used for serialization to JSON.
func (a *ScriptedSumAggregation) Name() stringName returns the name of the ScriptedSumAggregation, needed for the esquery.Aggregation interface.
TermsSource represents a terms value source in composite aggregations.
type TermsSource struct {
// contains filtered or unexported fields
}func Terms(name string, field string) *TermsSourceTerms creates a new TermsSource.
name: The name of the terms TermsSource. field: The name of the field referenced.
func (t *TermsSource) Map() map[string]interface{}Map returns a map representation of the TermsSource.
func (t *TermsSource) MissingBucket() *TermsSourceMissingBucket sets the missing_bucket flag to true in the TermsSource.
func (t *TermsSource) Order(order string) *TermsSourceOrder sets the sorting order for the TermsSource. Valid values: "asc", "desc".
Generated by gomarkdoc
Copyright (C) 2022-2023 [Greenbone AG][Greenbone AG]
Licensed under the GNU General Public License v3.0 or later.