git.iko.soy/typeable/bloodhound
on master help sign in
Add Max metrics aggregation
529c2fcGiorgio Marinelli
src/Database/V5/Bloodhound/Internal/Aggregation.hs+8
@@ -27,6 +27,7 @@ mkAggregations name aggregation = M.insert name aggregation emptyAggregations
27
27
28data Aggregation = TermsAgg TermsAggregation
28data Aggregation = TermsAgg TermsAggregation
29 | CardinalityAgg CardinalityAggregation
29 | CardinalityAgg CardinalityAggregation
30+ | MaxAgg MaxAggregation
30 | DateHistogramAgg DateHistogramAggregation
31 | DateHistogramAgg DateHistogramAggregation
31 | ValueCountAgg ValueCountAggregation
32 | ValueCountAgg ValueCountAggregation
32 | FilterAgg FilterAggregation
33 | FilterAgg FilterAggregation
@@ -58,6 +59,9 @@ instance ToJSON Aggregation where
58 ]
59 ]
59 ]
60 ]
60
61
62+ toJSON (MaxAgg (MaxAggregation field)) =
63+ object ["max" .= omitNulls [ "field" .= field ]]
64+
61 toJSON (DateHistogramAgg
65 toJSON (DateHistogramAgg
62 (DateHistogramAggregation field interval format
66 (DateHistogramAggregation field interval format
63 preZone postZone preOffset postOffset dateHistoAggs)) =
67 preZone postZone preOffset postOffset dateHistoAggs)) =
@@ -125,6 +129,10 @@ data CardinalityAggregation = CardinalityAggregation
125 precisionThreshold :: Maybe Int
129 precisionThreshold :: Maybe Int
126 } deriving (Eq, Show)
130 } deriving (Eq, Show)
127
131
132+data MaxAggregation = MaxAggregation
133+ { maxField :: FieldName
134+ } deriving (Eq, Show)
135+
128data DateHistogramAggregation = DateHistogramAggregation
136data DateHistogramAggregation = DateHistogramAggregation
129 { dateField :: FieldName
137 { dateField :: FieldName
130 , dateInterval :: Interval
138 , dateInterval :: Interval