diff options
author | Christopher Speller <crspeller@gmail.com> | 2017-06-21 19:06:17 -0700 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2017-06-21 19:06:17 -0700 |
commit | 42f28ab8e374137fe3f5d25424489d879d4724f8 (patch) | |
tree | 20353f2446b506d32e6d353b72a57bf48f070389 /vendor/gopkg.in/olivere/elastic.v5/search_aggs.go | |
parent | 6b39c308d882a0aeac533f8ab1d90b48a2ae4b5a (diff) | |
download | chat-42f28ab8e374137fe3f5d25424489d879d4724f8.tar.gz chat-42f28ab8e374137fe3f5d25424489d879d4724f8.tar.bz2 chat-42f28ab8e374137fe3f5d25424489d879d4724f8.zip |
Updating server dependancies (#6712)
Diffstat (limited to 'vendor/gopkg.in/olivere/elastic.v5/search_aggs.go')
-rw-r--r-- | vendor/gopkg.in/olivere/elastic.v5/search_aggs.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs.go index cb106dbf5..a43f8ddcc 100644 --- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs.go +++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs.go @@ -533,6 +533,21 @@ func (a Aggregations) StatsBucket(name string) (*AggregationPipelineStatsMetric, return nil, false } +// PercentilesBucket returns stats bucket pipeline aggregation results. +// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-percentiles-bucket-aggregation.html +func (a Aggregations) PercentilesBucket(name string) (*AggregationPipelinePercentilesMetric, bool) { + if raw, found := a[name]; found { + agg := new(AggregationPipelinePercentilesMetric) + if raw == nil { + return agg, true + } + if err := json.Unmarshal(*raw, agg); err == nil { + return agg, true + } + } + return nil, false +} + // MaxBucket returns maximum bucket pipeline aggregation results. // See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-max-bucket-aggregation.html func (a Aggregations) MaxBucket(name string) (*AggregationPipelineBucketMetricValue, bool) { @@ -1406,3 +1421,30 @@ func (a *AggregationPipelineStatsMetric) UnmarshalJSON(data []byte) error { a.Aggregations = aggs return nil } + +// -- Pipeline percentiles + +// AggregationPipelinePercentilesMetric is the value returned by a pipeline +// percentiles Metric aggregation +type AggregationPipelinePercentilesMetric struct { + Aggregations + + Values map[string]float64 // `json:"values"` + Meta map[string]interface{} // `json:"meta,omitempty"` +} + +// UnmarshalJSON decodes JSON data and initializes an AggregationPipelinePercentilesMetric structure. +func (a *AggregationPipelinePercentilesMetric) UnmarshalJSON(data []byte) error { + var aggs map[string]*json.RawMessage + if err := json.Unmarshal(data, &aggs); err != nil { + return err + } + if v, ok := aggs["values"]; ok && v != nil { + json.Unmarshal(*v, &a.Values) + } + if v, ok := aggs["meta"]; ok && v != nil { + json.Unmarshal(*v, &a.Meta) + } + a.Aggregations = aggs + return nil +} |