@@ -47,6 +47,7 @@ module Database.Bloodhound.Types
47 , mkDateHistogram
47 , mkDateHistogram
48 , mkDocVersion
48 , mkDocVersion
49 , docVersionNumber
49 , docVersionNumber
51 , toDateHistogram
52 , toDateHistogram
52 , omitNulls
53 , omitNulls
@@ -265,6 +266,7 @@ module Database.Bloodhound.Types
265 , HighlightTag(..)
266 , HighlightTag(..)
266 , HitHighlight
267 , HitHighlight
268 , TermsResult(..)
270 , TermsResult(..)
269 , DateHistogramResult(..)
271 , DateHistogramResult(..)
270 , DateRangeResult(..)
272 , DateRangeResult(..)
@@ -1792,6 +1794,8 @@ data BucketValue = TextValue Text
1792 | ScientificValue Scientific
1794 | ScientificValue Scientific
1793 | BoolValue Bool deriving (Show)
1795 | BoolValue Bool deriving (Show)
1797+data MissingResult = MissingResult { missingDocCount :: Int } deriving (Show)
1795data TermsResult = TermsResult { termKey :: BucketValue
1799data TermsResult = TermsResult { termKey :: BucketValue
1796 , termsDocCount :: Int
1800 , termsDocCount :: Int
1797 , termsAggs :: Maybe AggregationResults } deriving (Show)
1801 , termsAggs :: Maybe AggregationResults } deriving (Show)
@@ -1817,6 +1821,10 @@ toDateHistogram :: Text -> AggregationResults -> Maybe (Bucket DateHistogramResu
1817toDateHistogram t a = M.lookup t a >>= deserialize
1821toDateHistogram t a = M.lookup t a >>= deserialize
1818 where deserialize = parseMaybe parseJSON
1822 where deserialize = parseMaybe parseJSON
1824+toMissing :: Text -> AggregationResults -> Maybe MissingResult
1825+toMissing t a = M.lookup t a >>= deserialize
1826+ where deserialize = parseMaybe parseJSON
1820instance BucketAggregation TermsResult where
1828instance BucketAggregation TermsResult where
1821 key = termKey
1829 key = termKey
1822 docCount = termsDocCount
1830 docCount = termsDocCount
@@ -1843,6 +1851,10 @@ instance FromJSON BucketValue where
1843 parseJSON (Bool b) = return $ BoolValue b
1851 parseJSON (Bool b) = return $ BoolValue b
1844 parseJSON _ = mempty
1852 parseJSON _ = mempty
1854+instance FromJSON MissingResult where
1855+ parseJSON = withObject "MissingResult" parse
1856+ where parse v = MissingResult <$> v .: "doc_count"
1846instance FromJSON TermsResult where
1858instance FromJSON TermsResult where
1847 parseJSON (Object v) = TermsResult <$>
1859 parseJSON (Object v) = TermsResult <$>
1848 v .: "key" <*>
1860 v .: "key" <*>