@@ -203,6 +203,7 @@ module Database.Bloodhound.Types
203 , BucketAggregation(..)
203 , BucketAggregation(..)
204 , TermsAggregation(..)
204 , TermsAggregation(..)
205 , ValueCountAggregation(..)
205 , ValueCountAggregation(..)
206+ , FilterAggregation(..)
206 , DateHistogramAggregation(..)
207 , DateHistogramAggregation(..)
208 , Highlights(..)
209 , Highlights(..)
@@ -1319,7 +1320,8 @@ data Interval = Year
1320data Aggregation = TermsAgg TermsAggregation
1321data Aggregation = TermsAgg TermsAggregation
1321 | DateHistogramAgg DateHistogramAggregation
1322 | DateHistogramAgg DateHistogramAggregation
1322− | ValueCountAgg ValueCountAggregation deriving (Eq, Show)
1323+ | ValueCountAgg ValueCountAggregation
1324+ | FilterAgg FilterAggregation deriving (Eq, Show)
1325data TermsAggregation = TermsAggregation { term :: Either Text Text
1327data TermsAggregation = TermsAggregation { term :: Either Text Text
@@ -1345,9 +1347,14 @@ data DateHistogramAggregation = DateHistogramAggregation { dateField :: Fie
1345 , dateAggs :: Maybe Aggregations
1347 , dateAggs :: Maybe Aggregations
1346 } deriving (Eq, Show)
1348 } deriving (Eq, Show)
1350+-- | See <https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-valuecount-aggregation.html> for more information.
1348data ValueCountAggregation = FieldValueCount FieldName
1351data ValueCountAggregation = FieldValueCount FieldName
1349 | ScriptValueCount Script deriving (Eq, Show)
1352 | ScriptValueCount Script deriving (Eq, Show)
1354+-- | Single-bucket filter aggregations. See <https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html#search-aggregations-bucket-filter-aggregation> for more information.
1355+data FilterAggregation = FilterAggregation { faFilter :: Filter
1356+ , faAggs :: Maybe Aggregations} deriving (Eq, Show)
1351mkTermsAggregation :: Text -> TermsAggregation
1358mkTermsAggregation :: Text -> TermsAggregation
1352mkTermsAggregation t = TermsAggregation (Left t) Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
1359mkTermsAggregation t = TermsAggregation (Left t) Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
@@ -1424,6 +1431,9 @@ instance ToJSON Aggregation where
1424 where v = case a of
1431 where v = case a of
1425 (FieldValueCount (FieldName n)) -> object ["field" .= n]
1432 (FieldValueCount (FieldName n)) -> object ["field" .= n]
1426 (ScriptValueCount (Script s)) -> object ["script" .= s]
1433 (ScriptValueCount (Script s)) -> object ["script" .= s]
1434+ toJSON (FilterAgg (FilterAggregation filt ags)) =
1435+ omitNulls [ "filter" .= filt
1428type AggregationResults = M.Map Text Value
1438type AggregationResults = M.Map Text Value