Documentation
¶
Index ¶
- Constants
- Variables
- type AutoDateHistogramAggregation
- type AutoDateHistogramCalculator
- func (a *AutoDateHistogramCalculator) Buckets() []*search.Bucket
- func (a *AutoDateHistogramCalculator) Consume(d *search.DocumentMatch)
- func (a *AutoDateHistogramCalculator) Finish()
- func (a *AutoDateHistogramCalculator) Interval() string
- func (a *AutoDateHistogramCalculator) Len() int
- func (a *AutoDateHistogramCalculator) Less(i, j int) bool
- func (a *AutoDateHistogramCalculator) Merge(other search.Calculator)
- func (a *AutoDateHistogramCalculator) Other() int
- func (a *AutoDateHistogramCalculator) Swap(i, j int)
- type DateHistogramAggregation
- type DateHistogramCalculator
- func (a *DateHistogramCalculator) Buckets() []*search.Bucket
- func (a *DateHistogramCalculator) Consume(d *search.DocumentMatch)
- func (a *DateHistogramCalculator) Finish()
- func (a *DateHistogramCalculator) Len() int
- func (a *DateHistogramCalculator) Less(i, j int) bool
- func (a *DateHistogramCalculator) Merge(other search.Calculator)
- func (a *DateHistogramCalculator) Other() int
- func (a *DateHistogramCalculator) Swap(i, j int)
- type FilterAggregation
- type FilterCalculator
- type FilterPredicate
- type FiltersAggregation
- type FiltersCalculator
- type HistogramAggregation
- type HistogramBound
- type HistogramCalculator
- func (a *HistogramCalculator) Buckets() []*search.Bucket
- func (a *HistogramCalculator) Consume(d *search.DocumentMatch)
- func (a *HistogramCalculator) Finish()
- func (a *HistogramCalculator) Len() int
- func (a *HistogramCalculator) Less(i, j int) bool
- func (a *HistogramCalculator) Merge(other search.Calculator)
- func (a *HistogramCalculator) Other() int
- func (a *HistogramCalculator) Swap(i, j int)
- type MissingAggregation
- type MissingCalculator
- type MultiTermsAggregation
- type MultiTermsCalculator
- type PercentileRanksAggregation
- type PercentileRanksCalculator
- type PercentilesAggregation
- type PercentilesCalculator
- type SearchAggregation
- type StatsAggregation
- type StatsCalculator
- func (c *StatsCalculator) Avg() float64
- func (c *StatsCalculator) Consume(d *search.DocumentMatch)
- func (c *StatsCalculator) Count() uint64
- func (c *StatsCalculator) Extended() bool
- func (c *StatsCalculator) Finish()
- func (c *StatsCalculator) Max() float64
- func (c *StatsCalculator) Merge(other search.Calculator)
- func (c *StatsCalculator) Min() float64
- func (c *StatsCalculator) Sigma() float64
- func (c *StatsCalculator) StdDeviation() float64
- func (c *StatsCalculator) Sum() float64
- func (c *StatsCalculator) SumOfSquares() float64
- func (c *StatsCalculator) Variance() float64
- type TermsAggregation
- func (t *TermsAggregation) AddAggregation(name string, aggregation search.Aggregation)
- func (t *TermsAggregation) Calculator() search.Calculator
- func (t *TermsAggregation) Fields() []string
- func (t *TermsAggregation) SetKeyFilter(keep func(key string) bool)
- func (t *TermsAggregation) SetOrder(key string, asc bool)
- type TermsCalculator
- func (a *TermsCalculator) Buckets() []*search.Bucket
- func (a *TermsCalculator) Consume(d *search.DocumentMatch)
- func (a *TermsCalculator) Finish()
- func (a *TermsCalculator) Len() int
- func (a *TermsCalculator) Less(i, j int) bool
- func (a *TermsCalculator) Merge(other search.Calculator)
- func (a *TermsCalculator) Other() int
- func (a *TermsCalculator) Swap(i, j int)
- type TopHit
- type TopHitsAggregation
- type TopHitsCalculator
- func (c *TopHitsCalculator) Consume(d *search.DocumentMatch)
- func (c *TopHitsCalculator) Err() error
- func (c *TopHitsCalculator) Finish()
- func (c *TopHitsCalculator) Hits() []TopHit
- func (c *TopHitsCalculator) IncludeSortKey() bool
- func (c *TopHitsCalculator) MaxScore() float64
- func (c *TopHitsCalculator) Merge(other search.Calculator)
- func (c *TopHitsCalculator) Source() (enable bool, fields []string)
- func (c *TopHitsCalculator) Total() uint64
- type ValueCountAggregation
- type ValueCountCalculator
Constants ¶
const ( TextValueSource = iota TextValuesSource NumericValueSource NumericValuesSource BooleanValueSource BooleanValuesSource )
const ( OrderByCount = "_count" OrderByKey = "_key" )
Order keys understood by the terms style aggregations.
const MultiTermsKeySeparator = "|"
MultiTermsKeySeparator joins the per field terms of a composite key. A term containing the separator produces an ambiguous key_as_string, elasticsearch escapes it instead.
Variables ¶
var DefaultPercents = []float64{1, 5, 25, 50, 75, 95, 99}
DefaultPercents is the percents list elasticsearch uses when the percentiles aggregation doesn't specify one.
Functions ¶
This section is empty.
Types ¶
type AutoDateHistogramAggregation ¶
type AutoDateHistogramAggregation struct {
// contains filtered or unexported fields
}
func NewAutoDateHistogramAggregation ¶
func NewAutoDateHistogramAggregation( field search.FieldSource, buckets int, minimumInterval, format string, timeZone *time.Location, ) *AutoDateHistogramAggregation
NewAutoDateHistogramAggregation returns a termsAggregation field use to set the field use to terms aggregation
func (*AutoDateHistogramAggregation) AddAggregation ¶
func (t *AutoDateHistogramAggregation) AddAggregation(name string, aggregation search.Aggregation)
func (*AutoDateHistogramAggregation) Calculator ¶
func (t *AutoDateHistogramAggregation) Calculator() search.Calculator
func (*AutoDateHistogramAggregation) Fields ¶
func (t *AutoDateHistogramAggregation) Fields() []string
type AutoDateHistogramCalculator ¶
type AutoDateHistogramCalculator struct {
// contains filtered or unexported fields
}
func (*AutoDateHistogramCalculator) Buckets ¶
func (a *AutoDateHistogramCalculator) Buckets() []*search.Bucket
func (*AutoDateHistogramCalculator) Consume ¶
func (a *AutoDateHistogramCalculator) Consume(d *search.DocumentMatch)
func (*AutoDateHistogramCalculator) Finish ¶
func (a *AutoDateHistogramCalculator) Finish()
func (*AutoDateHistogramCalculator) Interval ¶
func (a *AutoDateHistogramCalculator) Interval() string
func (*AutoDateHistogramCalculator) Len ¶
func (a *AutoDateHistogramCalculator) Len() int
func (*AutoDateHistogramCalculator) Less ¶
func (a *AutoDateHistogramCalculator) Less(i, j int) bool
func (*AutoDateHistogramCalculator) Merge ¶
func (a *AutoDateHistogramCalculator) Merge(other search.Calculator)
func (*AutoDateHistogramCalculator) Other ¶
func (a *AutoDateHistogramCalculator) Other() int
func (*AutoDateHistogramCalculator) Swap ¶
func (a *AutoDateHistogramCalculator) Swap(i, j int)
type DateHistogramAggregation ¶
type DateHistogramAggregation struct {
// contains filtered or unexported fields
}
func NewDateHistogramAggregation ¶
func NewDateHistogramAggregation( field search.FieldSource, calendarInterval string, fixedInterval int64, format string, timeZone *time.Location, extendedBounds, hardBounds *HistogramBound, minDocCount, size int, ) *DateHistogramAggregation
NewDateHistogramAggregation returns a termsAggregation field use to set the field use to terms aggregation
func (*DateHistogramAggregation) AddAggregation ¶
func (t *DateHistogramAggregation) AddAggregation(name string, aggregation search.Aggregation)
func (*DateHistogramAggregation) Calculator ¶
func (t *DateHistogramAggregation) Calculator() search.Calculator
func (*DateHistogramAggregation) Fields ¶
func (t *DateHistogramAggregation) Fields() []string
type DateHistogramCalculator ¶
type DateHistogramCalculator struct {
// contains filtered or unexported fields
}
func (*DateHistogramCalculator) Buckets ¶
func (a *DateHistogramCalculator) Buckets() []*search.Bucket
func (*DateHistogramCalculator) Consume ¶
func (a *DateHistogramCalculator) Consume(d *search.DocumentMatch)
func (*DateHistogramCalculator) Finish ¶
func (a *DateHistogramCalculator) Finish()
func (*DateHistogramCalculator) Len ¶
func (a *DateHistogramCalculator) Len() int
func (*DateHistogramCalculator) Less ¶
func (a *DateHistogramCalculator) Less(i, j int) bool
func (*DateHistogramCalculator) Merge ¶
func (a *DateHistogramCalculator) Merge(other search.Calculator)
func (*DateHistogramCalculator) Other ¶
func (a *DateHistogramCalculator) Other() int
func (*DateHistogramCalculator) Swap ¶
func (a *DateHistogramCalculator) Swap(i, j int)
type FilterAggregation ¶
type FilterAggregation struct {
// contains filtered or unexported fields
}
FilterAggregation implements the elasticsearch single bucket aggregations that select a subset of the matching documents: [filter] and [nested].
func NewFilterAggregation ¶
func NewFilterAggregation(pred *FilterPredicate) *FilterAggregation
NewFilterAggregation returns the aggregation backing [filter].
func NewNestedAggregation ¶
func NewNestedAggregation(pathField, path string) *FilterAggregation
NewNestedAggregation returns the aggregation backing [nested]: a single bucket over the hidden documents that carry pathField == path.
Nested documents are hidden from root searches, so this aggregation only sees documents when the query itself selects them (for example a [nested] query). Otherwise the bucket is empty.
func NewReverseNestedAggregation ¶
func NewReverseNestedAggregation(pathField string) *FilterAggregation
NewReverseNestedAggregation returns the aggregation backing [reverse_nested]: a single bucket over the root documents, i.e. those without a nested path.
func (*FilterAggregation) AddAggregation ¶
func (a *FilterAggregation) AddAggregation(name string, aggregation search.Aggregation)
func (*FilterAggregation) Calculator ¶
func (a *FilterAggregation) Calculator() search.Calculator
func (*FilterAggregation) Fields ¶
func (a *FilterAggregation) Fields() []string
type FilterCalculator ¶
type FilterCalculator struct {
// contains filtered or unexported fields
}
FilterCalculator holds the single bucket of a [filter] aggregation. It deliberately implements neither MetricCalculator nor BucketCalculator: the response layer renders doc_count plus the sub-aggregations inline.
func (*FilterCalculator) Bucket ¶
func (c *FilterCalculator) Bucket() *search.Bucket
Bucket returns the bucket holding the sub-aggregations.
func (*FilterCalculator) Consume ¶
func (c *FilterCalculator) Consume(d *search.DocumentMatch)
func (*FilterCalculator) DocCount ¶
func (c *FilterCalculator) DocCount() uint64
func (*FilterCalculator) Finish ¶
func (c *FilterCalculator) Finish()
func (*FilterCalculator) Merge ¶
func (c *FilterCalculator) Merge(other search.Calculator)
type FilterPredicate ¶
type FilterPredicate struct {
Fields []string
Match func(*search.DocumentMatch) bool
}
FilterPredicate decides whether a document belongs to a bucket.
Calculators only see a search.DocumentMatch, so the query of a [filter] / [filters] aggregation is compiled into a doc-value predicate by the uquery layer. Fields lists the doc-value fields the predicate reads; they are reported through Aggregation.Fields so the collector loads them.
type FiltersAggregation ¶
type FiltersAggregation struct {
// contains filtered or unexported fields
}
FiltersAggregation implements the elasticsearch [filters] aggregation: one named bucket per filter, plus an optional bucket for the documents that match none of them. As in elasticsearch a document may land in several buckets at once.
func NewFiltersAggregation ¶
func NewFiltersAggregation(otherBucketKey string) *FiltersAggregation
NewFiltersAggregation returns the aggregation backing [filters]. otherBucketKey is empty when the other bucket is not requested.
func (*FiltersAggregation) AddAggregation ¶
func (a *FiltersAggregation) AddAggregation(name string, aggregation search.Aggregation)
func (*FiltersAggregation) AddFilter ¶
func (a *FiltersAggregation) AddFilter(name string, pred *FilterPredicate)
AddFilter registers a named filter; buckets keep the insertion order.
func (*FiltersAggregation) Calculator ¶
func (a *FiltersAggregation) Calculator() search.Calculator
func (*FiltersAggregation) Fields ¶
func (a *FiltersAggregation) Fields() []string
type FiltersCalculator ¶
type FiltersCalculator struct {
// contains filtered or unexported fields
}
FiltersCalculator holds one bucket per named filter. It deliberately does not implement search.BucketCalculator: the response layer renders the buckets as a keyed object, not as an array.
func (*FiltersCalculator) Consume ¶
func (c *FiltersCalculator) Consume(d *search.DocumentMatch)
func (*FiltersCalculator) Finish ¶
func (c *FiltersCalculator) Finish()
func (*FiltersCalculator) Merge ¶
func (c *FiltersCalculator) Merge(other search.Calculator)
func (*FiltersCalculator) NamedBuckets ¶
func (c *FiltersCalculator) NamedBuckets() []*search.Bucket
NamedBuckets returns the filter buckets in request order, followed by the other bucket when it was requested.
type HistogramAggregation ¶
type HistogramAggregation struct {
// contains filtered or unexported fields
}
func NewHistogramAggregation ¶
func NewHistogramAggregation( field search.FieldSource, interval, offset float64, extendedBounds, hardBounds *HistogramBound, minDocCount, size int, ) *HistogramAggregation
NewHistogramAggregation returns a termsAggregation field use to set the field use to terms aggregation
func (*HistogramAggregation) AddAggregation ¶
func (t *HistogramAggregation) AddAggregation(name string, aggregation search.Aggregation)
func (*HistogramAggregation) Calculator ¶
func (t *HistogramAggregation) Calculator() search.Calculator
func (*HistogramAggregation) Fields ¶
func (t *HistogramAggregation) Fields() []string
type HistogramBound ¶
type HistogramCalculator ¶
type HistogramCalculator struct {
// contains filtered or unexported fields
}
func (*HistogramCalculator) Buckets ¶
func (a *HistogramCalculator) Buckets() []*search.Bucket
func (*HistogramCalculator) Consume ¶
func (a *HistogramCalculator) Consume(d *search.DocumentMatch)
func (*HistogramCalculator) Finish ¶
func (a *HistogramCalculator) Finish()
func (*HistogramCalculator) Len ¶
func (a *HistogramCalculator) Len() int
func (*HistogramCalculator) Less ¶
func (a *HistogramCalculator) Less(i, j int) bool
func (*HistogramCalculator) Merge ¶
func (a *HistogramCalculator) Merge(other search.Calculator)
func (*HistogramCalculator) Other ¶
func (a *HistogramCalculator) Other() int
func (*HistogramCalculator) Swap ¶
func (a *HistogramCalculator) Swap(i, j int)
type MissingAggregation ¶
type MissingAggregation struct {
// contains filtered or unexported fields
}
MissingAggregation counts the matching documents that have no value for the field, as the elasticsearch missing aggregation does.
func NewMissingAggregation ¶
func NewMissingAggregation(src search.FieldSource) *MissingAggregation
NewMissingAggregation returns the aggregation backing [missing].
func (*MissingAggregation) Calculator ¶
func (a *MissingAggregation) Calculator() search.Calculator
func (*MissingAggregation) Fields ¶
func (a *MissingAggregation) Fields() []string
type MissingCalculator ¶
type MissingCalculator struct {
// contains filtered or unexported fields
}
MissingCalculator holds the doc count. It deliberately does not implement search.MetricCalculator so the response layer can render {"doc_count": n}.
func (*MissingCalculator) Consume ¶
func (c *MissingCalculator) Consume(d *search.DocumentMatch)
Consume counts a document when it carries no doc value for the field. FieldSource.Values reads DocumentMatch.DocValues, which also materializes numeric column fields, so this works for text and numeric fields alike.
func (*MissingCalculator) DocCount ¶
func (c *MissingCalculator) DocCount() uint64
func (*MissingCalculator) Finish ¶
func (c *MissingCalculator) Finish()
func (*MissingCalculator) Merge ¶
func (c *MissingCalculator) Merge(other search.Calculator)
type MultiTermsAggregation ¶
type MultiTermsAggregation struct {
// contains filtered or unexported fields
}
MultiTermsAggregation implements the elasticsearch [multi_terms] aggregation: one bucket per combination of the values of several fields. Documents missing a value for any of the fields are skipped, as in elasticsearch.
func NewMultiTermsAggregation ¶
func NewMultiTermsAggregation(srcs []search.FieldSource, valueTypes []int, size int) *MultiTermsAggregation
NewMultiTermsAggregation returns the aggregation backing [multi_terms]. valueTypes selects the value extraction per field, see the *ValueSource constants.
func (*MultiTermsAggregation) AddAggregation ¶
func (a *MultiTermsAggregation) AddAggregation(name string, aggregation search.Aggregation)
func (*MultiTermsAggregation) Calculator ¶
func (a *MultiTermsAggregation) Calculator() search.Calculator
func (*MultiTermsAggregation) Fields ¶
func (a *MultiTermsAggregation) Fields() []string
func (*MultiTermsAggregation) SetOrder ¶
func (a *MultiTermsAggregation) SetOrder(key string, asc bool)
SetOrder configures the bucket order, see TermsAggregation.SetOrder.
type MultiTermsCalculator ¶
type MultiTermsCalculator struct {
// contains filtered or unexported fields
}
MultiTermsCalculator buckets documents by composite key, ordered by descending doc count unless another order was requested.
func (*MultiTermsCalculator) Buckets ¶
func (a *MultiTermsCalculator) Buckets() []*search.Bucket
func (*MultiTermsCalculator) Consume ¶
func (a *MultiTermsCalculator) Consume(d *search.DocumentMatch)
func (*MultiTermsCalculator) Finish ¶
func (a *MultiTermsCalculator) Finish()
func (*MultiTermsCalculator) Key ¶
func (a *MultiTermsCalculator) Key(bucket *search.Bucket) []string
Key returns the per field terms of a bucket.
func (*MultiTermsCalculator) Merge ¶
func (a *MultiTermsCalculator) Merge(other search.Calculator)
type PercentileRanksAggregation ¶
type PercentileRanksAggregation struct {
// contains filtered or unexported fields
}
PercentileRanksAggregation implements the elasticsearch [percentile_ranks] aggregation: the percentage of the observed values that are below each of the requested values.
It keeps its own t-digest rather than wrapping riot's quantiles metric, which exposes the quantile function but not its inverse.
func NewPercentileRanksAggregation ¶
func NewPercentileRanksAggregation(src search.NumericValuesSource, values []float64) *PercentileRanksAggregation
NewPercentileRanksAggregation returns the aggregation backing [percentile_ranks].
func (*PercentileRanksAggregation) Calculator ¶
func (a *PercentileRanksAggregation) Calculator() search.Calculator
func (*PercentileRanksAggregation) Fields ¶
func (a *PercentileRanksAggregation) Fields() []string
type PercentileRanksCalculator ¶
type PercentileRanksCalculator struct {
// contains filtered or unexported fields
}
PercentileRanksCalculator accumulates the field values into a t-digest and reads the ranks back through its CDF. It does not implement search.MetricCalculator, the response layer type-switches on the concrete type.
func (*PercentileRanksCalculator) Consume ¶
func (c *PercentileRanksCalculator) Consume(d *search.DocumentMatch)
func (*PercentileRanksCalculator) Err ¶
func (c *PercentileRanksCalculator) Err() error
Err reports the first t-digest error seen, if any.
func (*PercentileRanksCalculator) Finish ¶
func (c *PercentileRanksCalculator) Finish()
func (*PercentileRanksCalculator) Merge ¶
func (c *PercentileRanksCalculator) Merge(other search.Calculator)
func (*PercentileRanksCalculator) Values ¶
func (c *PercentileRanksCalculator) Values() map[string]float64
Values returns the ranks keyed like elasticsearch does, e.g "500.0". Without any observation every rank is 0.
type PercentilesAggregation ¶
type PercentilesAggregation struct {
// contains filtered or unexported fields
}
PercentilesAggregation wraps riot's quantiles metric so that the requested percents travel with the calculator into the response layer.
func NewPercentilesAggregation ¶
func NewPercentilesAggregation(src search.NumericValuesSource, percents []float64) *PercentilesAggregation
NewPercentilesAggregation returns the aggregation backing [percentiles].
func (*PercentilesAggregation) Calculator ¶
func (a *PercentilesAggregation) Calculator() search.Calculator
func (*PercentilesAggregation) Fields ¶
func (a *PercentilesAggregation) Fields() []string
type PercentilesCalculator ¶
type PercentilesCalculator struct {
*aggregations.QuantilesCalculator
// contains filtered or unexported fields
}
PercentilesCalculator adds the percents list to riot's quantiles calculator. It does not implement search.MetricCalculator, the response layer type-switches on the concrete type.
func (*PercentilesCalculator) Merge ¶
func (c *PercentilesCalculator) Merge(other search.Calculator)
Merge unwraps the other calculator, the embedded riot implementation only accepts its own concrete type.
func (*PercentilesCalculator) Percents ¶
func (c *PercentilesCalculator) Percents() []float64
func (*PercentilesCalculator) Values ¶
func (c *PercentilesCalculator) Values() map[string]float64
Values returns the percentile values keyed like elasticsearch does, e.g "99.0". An empty t-digest yields NaN, reported as 0.
type SearchAggregation ¶
type SearchAggregation interface {
AddAggregation(name string, aggregation search.Aggregation)
}
type StatsAggregation ¶
type StatsAggregation struct {
// contains filtered or unexported fields
}
StatsAggregation implements the elasticsearch stats / extended_stats aggregations over a numeric field.
func NewExtendedStatsAggregation ¶
func NewExtendedStatsAggregation(src search.NumericValuesSource, sigma float64) *StatsAggregation
NewExtendedStatsAggregation returns the aggregation backing [extended_stats]. sigma is the std_deviation_bounds multiplier.
func NewStatsAggregation ¶
func NewStatsAggregation(src search.NumericValuesSource) *StatsAggregation
NewStatsAggregation returns the aggregation backing [stats].
func (*StatsAggregation) Calculator ¶
func (a *StatsAggregation) Calculator() search.Calculator
func (*StatsAggregation) Fields ¶
func (a *StatsAggregation) Fields() []string
type StatsCalculator ¶
type StatsCalculator struct {
// contains filtered or unexported fields
}
StatsCalculator accumulates count, sum, min, max and sum of squares so that every stats/extended_stats metric can be derived and shards can be merged.
It deliberately does not implement search.MetricCalculator: it has no single value, the response layer type-switches on the concrete type instead.
func (*StatsCalculator) Avg ¶
func (c *StatsCalculator) Avg() float64
Avg returns 0 when no value was collected, see Min.
func (*StatsCalculator) Consume ¶
func (c *StatsCalculator) Consume(d *search.DocumentMatch)
func (*StatsCalculator) Count ¶
func (c *StatsCalculator) Count() uint64
func (*StatsCalculator) Extended ¶
func (c *StatsCalculator) Extended() bool
Extended reports whether this calculator was built for [extended_stats].
func (*StatsCalculator) Finish ¶
func (c *StatsCalculator) Finish()
func (*StatsCalculator) Max ¶
func (c *StatsCalculator) Max() float64
Max returns 0 when no value was collected, see Min.
func (*StatsCalculator) Merge ¶
func (c *StatsCalculator) Merge(other search.Calculator)
func (*StatsCalculator) Min ¶
func (c *StatsCalculator) Min() float64
Min returns 0 when no value was collected. Elasticsearch returns null there, zed emits 0 to keep the response type a plain float.
func (*StatsCalculator) Sigma ¶
func (c *StatsCalculator) Sigma() float64
Sigma is the std_deviation_bounds multiplier.
func (*StatsCalculator) StdDeviation ¶
func (c *StatsCalculator) StdDeviation() float64
func (*StatsCalculator) Sum ¶
func (c *StatsCalculator) Sum() float64
func (*StatsCalculator) SumOfSquares ¶
func (c *StatsCalculator) SumOfSquares() float64
func (*StatsCalculator) Variance ¶
func (c *StatsCalculator) Variance() float64
Variance is the population variance, as elasticsearch reports it.
type TermsAggregation ¶
type TermsAggregation struct {
// contains filtered or unexported fields
}
func NewTermsAggregation ¶
func NewTermsAggregation(field search.FieldSource, valueType int, size int) *TermsAggregation
NewTermsAggregation returns a termsAggregation field use to set the field use to terms aggregation valueType use to set the value type, can be diy.TextValueSource / diy.TextValuesSource / diy.NumericValueSource / diy.NumericValuesSource
func (*TermsAggregation) AddAggregation ¶
func (t *TermsAggregation) AddAggregation(name string, aggregation search.Aggregation)
func (*TermsAggregation) Calculator ¶
func (t *TermsAggregation) Calculator() search.Calculator
func (*TermsAggregation) Fields ¶
func (t *TermsAggregation) Fields() []string
func (*TermsAggregation) SetKeyFilter ¶ added in v1.4.0
func (t *TermsAggregation) SetKeyFilter(keep func(key string) bool)
SetKeyFilter keeps only the buckets whose key matches, before the buckets are trimmed to size.
func (*TermsAggregation) SetOrder ¶
func (t *TermsAggregation) SetOrder(key string, asc bool)
SetOrder configures the bucket order. key is OrderByCount (the default), OrderByKey or the name of a sub-aggregation, optionally suffixed with the metric to read, e.g "grades.avg".
type TermsCalculator ¶
type TermsCalculator struct {
// contains filtered or unexported fields
}
func (*TermsCalculator) Buckets ¶
func (a *TermsCalculator) Buckets() []*search.Bucket
func (*TermsCalculator) Consume ¶
func (a *TermsCalculator) Consume(d *search.DocumentMatch)
func (*TermsCalculator) Finish ¶
func (a *TermsCalculator) Finish()
func (*TermsCalculator) Len ¶
func (a *TermsCalculator) Len() int
func (*TermsCalculator) Less ¶
func (a *TermsCalculator) Less(i, j int) bool
func (*TermsCalculator) Merge ¶
func (a *TermsCalculator) Merge(other search.Calculator)
func (*TermsCalculator) Other ¶
func (a *TermsCalculator) Other() int
func (*TermsCalculator) Swap ¶
func (a *TermsCalculator) Swap(i, j int)
type TopHit ¶
type TopHit struct {
ID string
Index string
Score float64
Source []byte
// Stored holds copies of the stored fields named by SetStoredFields.
Stored map[string][]byte
SortKey []byte // doc value of the sort field, nil when sorting by _score
}
TopHit is one document kept by a [top_hits] aggregation. Source holds the raw _source bytes; they are copied because the stored field visitor reuses its buffer once Consume returns.
type TopHitsAggregation ¶
type TopHitsAggregation struct {
// contains filtered or unexported fields
}
TopHitsAggregation implements the elasticsearch [top_hits] aggregation: the best documents of the enclosing bucket.
Only a single sort field is supported; sortField "" sorts by descending _score, as elasticsearch does by default.
func NewTopHitsAggregation ¶
func NewTopHitsAggregation(size, from int, sortField string, sortDesc bool) *TopHitsAggregation
NewTopHitsAggregation returns the aggregation backing [top_hits].
func (*TopHitsAggregation) Calculator ¶
func (a *TopHitsAggregation) Calculator() search.Calculator
func (*TopHitsAggregation) Fields ¶
func (a *TopHitsAggregation) Fields() []string
func (*TopHitsAggregation) SetIncludeSortKey ¶ added in v1.4.1
func (a *TopHitsAggregation) SetIncludeSortKey(include bool)
SetIncludeSortKey asks the response layer to render the sort key of each hit, for the node that merges the hits of several nodes.
func (*TopHitsAggregation) SetSource ¶
func (a *TopHitsAggregation) SetSource(enable bool, fields []string)
SetSource configures the _source filtering of the returned hits. The aggregation layer only carries the spec, the response layer applies it.
func (*TopHitsAggregation) SetStoredFields ¶ added in v1.3.0
func (a *TopHitsAggregation) SetStoredFields(fields []string)
SetStoredFields names the stored fields kept with each hit besides _source, e.g. vectors the response layer restores into _source.
type TopHitsCalculator ¶
type TopHitsCalculator struct {
// contains filtered or unexported fields
}
TopHitsCalculator keeps the best from+size documents of its bucket. It implements neither MetricCalculator nor BucketCalculator: the response layer type-switches on the concrete type.
func (*TopHitsCalculator) Consume ¶
func (c *TopHitsCalculator) Consume(d *search.DocumentMatch)
func (*TopHitsCalculator) Err ¶
func (c *TopHitsCalculator) Err() error
Err reports the first stored field error seen while collecting.
func (*TopHitsCalculator) Finish ¶
func (c *TopHitsCalculator) Finish()
Finish keeps the from+size best hits, so that a later Merge still has the documents skipped by from. Hits applies the window.
func (*TopHitsCalculator) Hits ¶
func (c *TopHitsCalculator) Hits() []TopHit
Hits returns the requested window of the ranked hits.
func (*TopHitsCalculator) IncludeSortKey ¶ added in v1.4.1
func (c *TopHitsCalculator) IncludeSortKey() bool
IncludeSortKey reports whether the hits are rendered with their sort key.
func (*TopHitsCalculator) MaxScore ¶
func (c *TopHitsCalculator) MaxScore() float64
MaxScore is the best score of the kept hits, 0 when there is none.
func (*TopHitsCalculator) Merge ¶
func (c *TopHitsCalculator) Merge(other search.Calculator)
func (*TopHitsCalculator) Source ¶
func (c *TopHitsCalculator) Source() (enable bool, fields []string)
Source returns the _source filtering requested for the hits.
func (*TopHitsCalculator) Total ¶
func (c *TopHitsCalculator) Total() uint64
Total is the number of documents in the bucket, not the number of hits kept.
type ValueCountAggregation ¶
type ValueCountAggregation struct {
// contains filtered or unexported fields
}
ValueCountAggregation counts the number of field values, not the number of matching documents, as elasticsearch value_count does.
func NewValueCountAggregation ¶
func NewValueCountAggregation(src search.FieldSource, valueType int) *ValueCountAggregation
NewValueCountAggregation returns the aggregation backing [value_count]. valueType selects how values are extracted, see the *ValueSource constants.
func (*ValueCountAggregation) Calculator ¶
func (a *ValueCountAggregation) Calculator() search.Calculator
func (*ValueCountAggregation) Fields ¶
func (a *ValueCountAggregation) Fields() []string
type ValueCountCalculator ¶
type ValueCountCalculator struct {
// contains filtered or unexported fields
}
ValueCountCalculator implements search.MetricCalculator so the generic metric response path renders it as {"value": n}.
func (*ValueCountCalculator) Consume ¶
func (c *ValueCountCalculator) Consume(d *search.DocumentMatch)
func (*ValueCountCalculator) Finish ¶
func (c *ValueCountCalculator) Finish()
func (*ValueCountCalculator) Merge ¶
func (c *ValueCountCalculator) Merge(other search.Calculator)
func (*ValueCountCalculator) Value ¶
func (c *ValueCountCalculator) Value() float64