Add Max metrics aggregation

This commit is contained in:
Giorgio Marinelli 2019-08-12 18:04:02 +02:00
parent 4fa060a90e
commit 529c2fc68e

View File

@ -27,6 +27,7 @@ mkAggregations name aggregation = M.insert name aggregation emptyAggregations
data Aggregation = TermsAgg TermsAggregation
| CardinalityAgg CardinalityAggregation
| MaxAgg MaxAggregation
| DateHistogramAgg DateHistogramAggregation
| ValueCountAgg ValueCountAggregation
| FilterAgg FilterAggregation
@ -58,6 +59,9 @@ instance ToJSON Aggregation where
]
]
toJSON (MaxAgg (MaxAggregation field)) =
object ["max" .= omitNulls [ "field" .= field ]]
toJSON (DateHistogramAgg
(DateHistogramAggregation field interval format
preZone postZone preOffset postOffset dateHistoAggs)) =
@ -125,6 +129,10 @@ data CardinalityAggregation = CardinalityAggregation
precisionThreshold :: Maybe Int
} deriving (Eq, Show)
data MaxAggregation = MaxAggregation
{ maxField :: FieldName
} deriving (Eq, Show)
data DateHistogramAggregation = DateHistogramAggregation
{ dateField :: FieldName
, dateInterval :: Interval