git.iko.soy/typeable/bloodhound
on master help sign in
Retain specific key data type in BucketAggregation
commit8f0a40ced2bab1de2d186045418e9cabeeafb118 authorMHova <mho@sumall.com> dateThu 21 Jan 2016, 09:47 (11 years ago) parentcba1a57
1 file changed+4−6
src/Database/Bloodhound/Types.hs+4−6
src/Database/Bloodhound/Types.hs+4−6
@@ -1739,7 +1739,7 @@ instance ToJSON DateMathExpr where
17391739type AggregationResults = M.Map Text Value
17401740
17411741class BucketAggregation a where
1742− key :: a -> Text
1742+ key :: a -> BucketValue
17431743 docCount :: a -> Int
17441744 aggs :: a -> Maybe AggregationResults
17451745
@@ -1776,19 +1776,17 @@ toDateHistogram t a = M.lookup t a >>= deserialize
17761776 where deserialize = parseMaybe parseJSON
17771777
17781778instance BucketAggregation TermsResult where
1779− key (TermsResult (TextValue t) _ _) = t
1780− key (TermsResult (ScientificValue s) _ _) = T.pack $ show s
1781− key (TermsResult (BoolValue b) _ _) = T.pack $ show b
1779+ key = termKey
17821780 docCount = termsDocCount
17831781 aggs = termsAggs
17841782
17851783instance BucketAggregation DateHistogramResult where
1786− key = showText . dateKey
1784+ key = TextValue . showText . dateKey
17871785 docCount = dateDocCount
17881786 aggs = dateHistogramAggs
17891787
17901788instance BucketAggregation DateRangeResult where
1791− key = dateRangeKey
1789+ key = TextValue . dateRangeKey
17921790 docCount = dateRangeDocCount
17931791 aggs = dateRangeAggs
17941792