@@ -47,6 +47,8 @@ module Database.V5.Bloodhound.Types
47 , mkDateHistogram
47 , mkDateHistogram
48 , mkCardinalityAggregation
48 , mkCardinalityAggregation
49 , mkDocVersion
49 , mkDocVersion
51+ , mkExtendedStatsAggregation
50 , docVersionNumber
52 , docVersionNumber
51 , toMissing
53 , toMissing
@@ -341,6 +343,7 @@ module Database.V5.Bloodhound.Types
341 , DateMathModifier(..)
343 , DateMathModifier(..)
342 , DateMathUnit(..)
344 , DateMathUnit(..)
343 , TopHitsAggregation(..)
345 , TopHitsAggregation(..)
346+ , StatisticsAggregation(..)
345 , Highlights(..)
348 , Highlights(..)
346 , FieldHighlight(..)
349 , FieldHighlight(..)
@@ -1715,6 +1718,7 @@ data Aggregation = TermsAgg TermsAggregation
1715 | DateRangeAgg DateRangeAggregation
1718 | DateRangeAgg DateRangeAggregation
1716 | MissingAgg MissingAggregation
1719 | MissingAgg MissingAggregation
1717 | TopHitsAgg TopHitsAggregation
1720 | TopHitsAgg TopHitsAggregation
1721+ | StatsAgg StatisticsAggregation
1718 deriving (Eq, Read, Show, Generic, Typeable)
1722 deriving (Eq, Read, Show, Generic, Typeable)
1720data TopHitsAggregation = TopHitsAggregation
1724data TopHitsAggregation = TopHitsAggregation
@@ -1792,6 +1796,14 @@ data ValueCountAggregation = FieldValueCount FieldName
1792data FilterAggregation = FilterAggregation { faFilter :: Filter
1796data FilterAggregation = FilterAggregation { faFilter :: Filter
1793 , faAggs :: Maybe Aggregations} deriving (Eq, Read, Show, Generic, Typeable)
1797 , faAggs :: Maybe Aggregations} deriving (Eq, Read, Show, Generic, Typeable)
1799+data StatisticsAggregation = StatisticsAggregation { statsType :: StatsType
1800+ , statsField :: FieldName } deriving (Eq, Read, Show, Generic, Typeable)
1805+ deriving (Eq, Read, Show, Generic, Typeable)
1795mkTermsAggregation :: Text -> TermsAggregation
1807mkTermsAggregation :: Text -> TermsAggregation
1796mkTermsAggregation t = TermsAggregation (Left t) Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
1808mkTermsAggregation t = TermsAggregation (Left t) Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
@@ -1804,6 +1816,12 @@ mkDateHistogram t i = DateHistogramAggregation t i Nothing Nothing Nothing Nothi
1804mkCardinalityAggregation :: FieldName -> CardinalityAggregation
1816mkCardinalityAggregation :: FieldName -> CardinalityAggregation
1805mkCardinalityAggregation t = CardinalityAggregation t Nothing
1817mkCardinalityAggregation t = CardinalityAggregation t Nothing
1819+mkStatsAggregation :: FieldName -> StatisticsAggregation
1820+mkStatsAggregation = StatisticsAggregation Basic
1822+mkExtendedStatsAggregation :: FieldName -> StatisticsAggregation
1823+mkExtendedStatsAggregation = StatisticsAggregation Extended
1807instance ToJSON Version where
1825instance ToJSON Version where
1808 toJSON Version {..} = object ["number" .= number
1826 toJSON Version {..} = object ["number" .= number
1809 ,"build_hash" .= build_hash
1827 ,"build_hash" .= build_hash
@@ -1928,6 +1946,12 @@ instance ToJSON Aggregation where
1949+ toJSON (StatsAgg (StatisticsAggregation typ field)) =
1950+ object [stType .= omitNulls [ "field" .= field ]]
1952+ stType | typ == Basic = "stats"
1953+ | otherwise = "extended_stats"
1931instance ToJSON DateRangeAggregation where
1955instance ToJSON DateRangeAggregation where
1932 toJSON DateRangeAggregation {..} =
1956 toJSON DateRangeAggregation {..} =
1933 omitNulls [ "field" .= draField
1957 omitNulls [ "field" .= draField