@@ -1814,15 +1814,16 @@ data DateRangeResult = DateRangeResult { dateRangeKey :: Text
18141814 , dateRangeAggs :: Maybe AggregationResults } deriving (Show, Eq, Generic, Typeable)
18151815
18161816toTerms :: Text -> AggregationResults -> Maybe (Bucket TermsResult)
1817−toTerms t a = M.lookup t a >>= deserialize
1818− where deserialize = parseMaybe parseJSON
1817+toTerms = toAggResult
18191818
18201819toDateHistogram :: Text -> AggregationResults -> Maybe (Bucket DateHistogramResult)
1821−toDateHistogram t a = M.lookup t a >>= deserialize
1822− where deserialize = parseMaybe parseJSON
1820+toDateHistogram = toAggResult
18231821
18241822toMissing :: Text -> AggregationResults -> Maybe MissingResult
1825−toMissing t a = M.lookup t a >>= deserialize
1823+toMissing = toAggResult
1824+
1825+toAggResult :: (FromJSON a) => Text -> AggregationResults -> Maybe a
1826+toAggResult t a = M.lookup t a >>= deserialize
18261827 where deserialize = parseMaybe parseJSON
18271828
18281829instance BucketAggregation TermsResult where