git.iko.soy/typeable/bloodhound
on master help sign in
Also add Semigroup superclass to v5
edaac67Michael Xavier
src/Database/V5/Bloodhound/Types.hs+107−103
@@ -364,40 +364,44 @@ module Database.V5.Bloodhound.Types
364 , EsPassword(..)
364 , EsPassword(..)
365 ) where
365 ) where
366
366
367−import Control.Applicative as A
367+import Control.Applicative as A
368−import Control.Arrow (first)
368+import Control.Arrow (first)
369import Control.Monad.Catch
369import Control.Monad.Catch
370import Control.Monad.Except
370import Control.Monad.Except
371import Control.Monad.Reader
371import Control.Monad.Reader
372import Control.Monad.State
372import Control.Monad.State
373import Control.Monad.Writer
373import Control.Monad.Writer
374import Data.Aeson
374import Data.Aeson
375−import Data.Aeson.Types (Pair, Parser, emptyObject,
375+import Data.Aeson.Types (Pair, Parser,
376+ emptyObject,
376− parseEither, parseMaybe)
377+ parseEither, parseMaybe)
377−import qualified Data.ByteString.Lazy.Char8 as L
378+import qualified Data.ByteString.Lazy.Char8 as L
378import Data.Char
379import Data.Char
379−import Data.Hashable (Hashable)
380+import Data.Hashable (Hashable)
380−import qualified Data.HashMap.Strict as HM
381+import qualified Data.HashMap.Strict as HM
381−import Data.List (foldl', intercalate, nub)
382+import Data.List (foldl', intercalate,
383+ nub)
382−import Data.List.NonEmpty (NonEmpty (..), toList)
384+import Data.List.NonEmpty (NonEmpty (..), toList)
383−import qualified Data.Map.Strict as M
385+import qualified Data.Map.Strict as M
384import Data.Maybe
386import Data.Maybe
385−import Data.Scientific (Scientific)
387+import Data.Scientific (Scientific)
386−import Data.Text (Text)
388+import Data.Semigroup
389+import Data.Text (Text)
387−import qualified Data.Text as T
390+import qualified Data.Text as T
388import Data.Time.Calendar
391import Data.Time.Calendar
389−import Data.Time.Clock (NominalDiffTime, UTCTime)
392+import Data.Time.Clock (NominalDiffTime,
393+ UTCTime)
390import Data.Time.Clock.POSIX
394import Data.Time.Clock.POSIX
391−import qualified Data.Traversable as DT
395+import qualified Data.Traversable as DT
392−import Data.Typeable (Typeable)
396+import Data.Typeable (Typeable)
393−import qualified Data.Vector as V
397+import qualified Data.Vector as V
394−import qualified Data.Version as Vers
398+import qualified Data.Version as Vers
395import GHC.Enum
399import GHC.Enum
396−import GHC.Generics (Generic)
400+import GHC.Generics (Generic)
397import Network.HTTP.Client
401import Network.HTTP.Client
398−import qualified Network.HTTP.Types.Method as NHTM
402+import qualified Network.HTTP.Types.Method as NHTM
399−import qualified Text.ParserCombinators.ReadP as RP
403+import qualified Text.ParserCombinators.ReadP as RP
400−import qualified Text.Read as TR
404+import qualified Text.Read as TR
401
405
402import Database.V5.Bloodhound.Types.Class
406import Database.V5.Bloodhound.Types.Class
403import Database.V5.Bloodhound.Types.Internal
407import Database.V5.Bloodhound.Types.Internal
@@ -452,11 +456,11 @@ runBH :: BHEnv -> BH m a -> m a
452runBH e f = runReaderT (unBH f) e
456runBH e f = runReaderT (unBH f) e
453
457
454{-| 'Version' is embedded in 'Status' -}
458{-| 'Version' is embedded in 'Status' -}
455−data Version = Version { number :: VersionNumber
459+data Version = Version { number :: VersionNumber
456− , build_hash :: BuildHash
460+ , build_hash :: BuildHash
457− , build_date :: UTCTime
461+ , build_date :: UTCTime
458− , build_snapshot :: Bool
462+ , build_snapshot :: Bool
459− , lucene_version :: VersionNumber } deriving (Eq, Read, Show, Generic, Typeable)
463+ , lucene_version :: VersionNumber } deriving (Eq, Read, Show, Generic, Typeable)
460
464
461-- | Traditional software versioning number
465-- | Traditional software versioning number
462newtype VersionNumber = VersionNumber { versionNumber :: Vers.Version
466newtype VersionNumber = VersionNumber { versionNumber :: Vers.Version
@@ -494,7 +498,7 @@ defaultIndexSettings = IndexSettings (ShardCount 3) (ReplicaCount 2)
494 for more info.
498 for more info.
495-}
499-}
496data ForceMergeIndexSettings =
500data ForceMergeIndexSettings =
497− ForceMergeIndexSettings { maxNumSegments :: Maybe Int
501+ ForceMergeIndexSettings { maxNumSegments :: Maybe Int
498 -- ^ Number of segments to optimize to. 1 will fully optimize the index. If omitted, the default behavior is to only optimize if the server deems it necessary.
502 -- ^ Number of segments to optimize to. 1 will fully optimize the index. If omitted, the default behavior is to only optimize if the server deems it necessary.
499 , onlyExpungeDeletes :: Bool
503 , onlyExpungeDeletes :: Bool
500 -- ^ Should the optimize process only expunge segments with deletes in them? If the purpose of the optimization is to free disk space, this should be set to True.
504 -- ^ Should the optimize process only expunge segments with deletes in them? If the purpose of the optimization is to free disk space, this should be set to True.
@@ -847,8 +851,8 @@ data SortSpec = DefaultSortSpec DefaultSort
847{-| 'DefaultSort' is usually the kind of 'SortSpec' you'll want. There's a
851{-| 'DefaultSort' is usually the kind of 'SortSpec' you'll want. There's a
848 'mkSort' convenience function for when you want to specify only the most
852 'mkSort' convenience function for when you want to specify only the most
849 common parameters.
853 common parameters.
850−
854+
851− The `ignoreUnmapped`, when `Just` field is used to set the elastic 'unmapped_type'
855+ The `ignoreUnmapped`, when `Just` field is used to set the elastic 'unmapped_type'
852
856
853<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#search-request-sort>
857<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#search-request-sort>
854-}
858-}
@@ -1206,7 +1210,7 @@ data Query =
1206 deriving (Eq, Read, Show, Generic, Typeable)
1210 deriving (Eq, Read, Show, Generic, Typeable)
1207
1211
1208-- | As of Elastic 2.0, 'Filters' are just 'Queries' housed in a Bool Query, and
1212-- | As of Elastic 2.0, 'Filters' are just 'Queries' housed in a Bool Query, and
1209−-- flagged in a different context.
1213+-- flagged in a different context.
1210newtype Filter = Filter { unFilter :: Query }
1214newtype Filter = Filter { unFilter :: Query }
1211 deriving (Eq, Read, Show, Generic, Typeable)
1215 deriving (Eq, Read, Show, Generic, Typeable)
1212
1216
@@ -1631,12 +1635,12 @@ data SearchHits a =
1631 , maxScore :: Score
1635 , maxScore :: Score
1632 , hits :: [Hit a] } deriving (Eq, Read, Show, Generic, Typeable)
1636 , hits :: [Hit a] } deriving (Eq, Read, Show, Generic, Typeable)
1633
1637
1638+instance Semigroup (SearchHits a) where
1639+ (SearchHits ta ma ha) <> (SearchHits tb mb hb) = SearchHits (ta + tb) (max ma mb) (ha <> hb)
1634
1640
1635instance Monoid (SearchHits a) where
1641instance Monoid (SearchHits a) where
1636 mempty = SearchHits 0 Nothing mempty
1642 mempty = SearchHits 0 Nothing mempty
1637− mappend (SearchHits ta ma ha) (SearchHits tb mb hb) =
1643+ mappend = (<>)
1638− SearchHits (ta + tb) (max ma mb) (ha <> hb)
1639−
1640
1644
1641data Hit a =
1645data Hit a =
1642 Hit { hitIndex :: IndexName
1646 Hit { hitIndex :: IndexName
@@ -1659,7 +1663,7 @@ showText = T.pack . show
1659readMay :: Read a => String -> Maybe a
1663readMay :: Read a => String -> Maybe a
1660readMay s = case reads s of
1664readMay s = case reads s of
1661 (a, ""):_ -> Just a
1665 (a, ""):_ -> Just a
1662− _ -> Nothing
1666+ _ -> Nothing
1663
1667
1664parseReadText :: Read a => Text -> Parser a
1668parseReadText :: Read a => Text -> Parser a
1665parseReadText = maybe mzero return . readMay . T.unpack
1669parseReadText = maybe mzero return . readMay . T.unpack
@@ -1708,8 +1712,8 @@ data Aggregation = TermsAgg TermsAggregation
1708 | ValueCountAgg ValueCountAggregation
1712 | ValueCountAgg ValueCountAggregation
1709 | FilterAgg FilterAggregation
1713 | FilterAgg FilterAggregation
1710 | DateRangeAgg DateRangeAggregation
1714 | DateRangeAgg DateRangeAggregation
1711− | MissingAgg MissingAggregation
1715+ | MissingAgg MissingAggregation
1712− | TopHitsAgg TopHitsAggregation
1716+ | TopHitsAgg TopHitsAggregation
1713 deriving (Eq, Read, Show, Generic, Typeable)
1717 deriving (Eq, Read, Show, Generic, Typeable)
1714
1718
1715data TopHitsAggregation = TopHitsAggregation
1719data TopHitsAggregation = TopHitsAggregation
@@ -1846,21 +1850,21 @@ instance ToJSON ExecutionHint where
1846 toJSON Map = "map"
1850 toJSON Map = "map"
1847
1851
1848instance ToJSON Interval where
1852instance ToJSON Interval where
1849− toJSON Year = "year"
1853+ toJSON Year = "year"
1850 toJSON Quarter = "quarter"
1854 toJSON Quarter = "quarter"
1851− toJSON Month = "month"
1855+ toJSON Month = "month"
1852− toJSON Week = "week"
1856+ toJSON Week = "week"
1853− toJSON Day = "day"
1857+ toJSON Day = "day"
1854− toJSON Hour = "hour"
1858+ toJSON Hour = "hour"
1855− toJSON Minute = "minute"
1859+ toJSON Minute = "minute"
1856− toJSON Second = "second"
1860+ toJSON Second = "second"
1857
1861
1858instance Show TimeInterval where
1862instance Show TimeInterval where
1859− show Weeks = "w"
1863+ show Weeks = "w"
1860− show Days = "d"
1864+ show Days = "d"
1861− show Hours = "h"
1865+ show Hours = "h"
1862− show Minutes = "m"
1866+ show Minutes = "m"
1863− show Seconds = "s"
1867+ show Seconds = "s"
1864
1868
1865instance Read TimeInterval where
1869instance Read TimeInterval where
1866 readPrec = f =<< TR.get
1870 readPrec = f =<< TR.get
@@ -1916,7 +1920,7 @@ instance ToJSON Aggregation where
1916 toJSON (MissingAgg (MissingAggregation{..})) =
1920 toJSON (MissingAgg (MissingAggregation{..})) =
1917 object ["missing" .= object ["field" .= maField]]
1921 object ["missing" .= object ["field" .= maField]]
1918
1922
1919− toJSON (TopHitsAgg (TopHitsAggregation mfrom msize msort)) =
1923+ toJSON (TopHitsAgg (TopHitsAggregation mfrom msize msort)) =
1920 omitNulls ["top_hits" .= omitNulls [ "size" .= msize
1924 omitNulls ["top_hits" .= omitNulls [ "size" .= msize
1921 , "from" .= mfrom
1925 , "from" .= mfrom
1922 , "sort" .= msort
1926 , "sort" .= msort
@@ -1931,22 +1935,22 @@ instance ToJSON DateRangeAggregation where
1931 ]
1935 ]
1932
1936
1933instance ToJSON DateRangeAggRange where
1937instance ToJSON DateRangeAggRange where
1934− toJSON (DateRangeFrom e) = object [ "from" .= e ]
1938+ toJSON (DateRangeFrom e) = object [ "from" .= e ]
1935− toJSON (DateRangeTo e) = object [ "to" .= e ]
1939+ toJSON (DateRangeTo e) = object [ "to" .= e ]
1936 toJSON (DateRangeFromAndTo f t) = object [ "from" .= f, "to" .= t ]
1940 toJSON (DateRangeFromAndTo f t) = object [ "from" .= f, "to" .= t ]
1937
1941
1938instance ToJSON DateMathExpr where
1942instance ToJSON DateMathExpr where
1939 toJSON (DateMathExpr a mods) = String (fmtA a <> mconcat (fmtMod <$> mods))
1943 toJSON (DateMathExpr a mods) = String (fmtA a <> mconcat (fmtMod <$> mods))
1940− where fmtA DMNow = "now"
1944+ where fmtA DMNow = "now"
1941 fmtA (DMDate date) = (T.pack $ showGregorian date) <> "||"
1945 fmtA (DMDate date) = (T.pack $ showGregorian date) <> "||"
1942− fmtMod (AddTime n u) = "+" <> showText n <> fmtU u
1946+ fmtMod (AddTime n u) = "+" <> showText n <> fmtU u
1943 fmtMod (SubtractTime n u) = "-" <> showText n <> fmtU u
1947 fmtMod (SubtractTime n u) = "-" <> showText n <> fmtU u
1944− fmtMod (RoundDownTo u) = "/" <> fmtU u
1948+ fmtMod (RoundDownTo u) = "/" <> fmtU u
1945− fmtU DMYear = "y"
1949+ fmtU DMYear = "y"
1946− fmtU DMMonth = "M"
1950+ fmtU DMMonth = "M"
1947− fmtU DMWeek = "w"
1951+ fmtU DMWeek = "w"
1948− fmtU DMDay = "d"
1952+ fmtU DMDay = "d"
1949− fmtU DMHour = "h"
1953+ fmtU DMHour = "h"
1950 fmtU DMMinute = "m"
1954 fmtU DMMinute = "m"
1951 fmtU DMSecond = "s"
1955 fmtU DMSecond = "s"
1952
1956
@@ -2026,8 +2030,8 @@ instance (FromJSON a, BucketAggregation a) => FromJSON (Bucket a) where
2026instance FromJSON BucketValue where
2030instance FromJSON BucketValue where
2027 parseJSON (String t) = return $ TextValue t
2031 parseJSON (String t) = return $ TextValue t
2028 parseJSON (Number s) = return $ ScientificValue s
2032 parseJSON (Number s) = return $ ScientificValue s
2029− parseJSON (Bool b) = return $ BoolValue b
2033+ parseJSON (Bool b) = return $ BoolValue b
2030− parseJSON _ = mempty
2034+ parseJSON _ = mempty
2031
2035
2032instance FromJSON MissingResult where
2036instance FromJSON MissingResult where
2033 parseJSON = withObject "MissingResult" parse
2037 parseJSON = withObject "MissingResult" parse
@@ -2086,11 +2090,11 @@ fieldTagged f o = case HM.toList o of
2086 _ -> fail "Expected object with 1 field-named key"
2090 _ -> fail "Expected object with 1 field-named key"
2087
2091
2088-- Try to get an AggregationResults when we don't know the
2092-- Try to get an AggregationResults when we don't know the
2089−-- field name. We filter out the known keys to try to minimize the noise.
2093+-- field name. We filter out the known keys to try to minimize the noise.
2090getNamedSubAgg :: Object -> [Text] -> Maybe AggregationResults
2094getNamedSubAgg :: Object -> [Text] -> Maybe AggregationResults
2091getNamedSubAgg o knownKeys = maggRes
2095getNamedSubAgg o knownKeys = maggRes
2092 where unknownKeys = HM.filterWithKey (\k _ -> k `notElem` knownKeys) o
2096 where unknownKeys = HM.filterWithKey (\k _ -> k `notElem` knownKeys) o
2093− maggRes
2097+ maggRes
2094 | HM.null unknownKeys = Nothing
2098 | HM.null unknownKeys = Nothing
2095 | otherwise = Just . M.fromList $ HM.toList unknownKeys
2099 | otherwise = Just . M.fromList $ HM.toList unknownKeys
2096
2100
@@ -2188,7 +2192,7 @@ instance ToJSON Query where
2188 object ["exists" .= object
2192 object ["exists" .= object
2189 ["field" .= fieldName]
2193 ["field" .= fieldName]
2190 ]
2194 ]
2191− toJSON QueryMatchNoneQuery =
2195+ toJSON QueryMatchNoneQuery =
2192 object ["match_none" .= object []]
2196 object ["match_none" .= object []]
2193
2197
2194instance FromJSON Query where
2198instance FromJSON Query where
@@ -2259,9 +2263,9 @@ instance FromJSON Query where
2259
2263
2260omitNulls :: [(Text, Value)] -> Value
2264omitNulls :: [(Text, Value)] -> Value
2261omitNulls = object . filter notNull where
2265omitNulls = object . filter notNull where
2262− notNull (_, Null) = False
2266+ notNull (_, Null) = False
2263 notNull (_, Array a) = (not . V.null) a
2267 notNull (_, Array a) = (not . V.null) a
2264− notNull _ = True
2268+ notNull _ = True
2265
2269
2266instance ToJSON SimpleQueryStringQuery where
2270instance ToJSON SimpleQueryStringQuery where
2267 toJSON SimpleQueryStringQuery {..} =
2271 toJSON SimpleQueryStringQuery {..} =
@@ -2804,10 +2808,10 @@ instance FromJSON MultiMatchQuery where
2804 <*> o .:? "lenient"
2808 <*> o .:? "lenient"
2805
2809
2806instance ToJSON MultiMatchQueryType where
2810instance ToJSON MultiMatchQueryType where
2807− toJSON MultiMatchBestFields = "best_fields"
2811+ toJSON MultiMatchBestFields = "best_fields"
2808− toJSON MultiMatchMostFields = "most_fields"
2812+ toJSON MultiMatchMostFields = "most_fields"
2809− toJSON MultiMatchCrossFields = "cross_fields"
2813+ toJSON MultiMatchCrossFields = "cross_fields"
2810− toJSON MultiMatchPhrase = "phrase"
2814+ toJSON MultiMatchPhrase = "phrase"
2811 toJSON MultiMatchPhrasePrefix = "phrase_prefix"
2815 toJSON MultiMatchPhrasePrefix = "phrase_prefix"
2812
2816
2813instance FromJSON MultiMatchQueryType where
2817instance FromJSON MultiMatchQueryType where
@@ -2821,7 +2825,7 @@ instance FromJSON MultiMatchQueryType where
2821
2825
2822instance ToJSON BooleanOperator where
2826instance ToJSON BooleanOperator where
2823 toJSON And = String "and"
2827 toJSON And = String "and"
2824− toJSON Or = String "or"
2828+ toJSON Or = String "or"
2825
2829
2826instance FromJSON BooleanOperator where
2830instance FromJSON BooleanOperator where
2827 parseJSON = withText "BooleanOperator" parse
2831 parseJSON = withText "BooleanOperator" parse
@@ -2840,7 +2844,7 @@ instance FromJSON ZeroTermsQuery where
2840 parse q = fail ("Unexpected ZeroTermsQuery: " <> show q)
2844 parse q = fail ("Unexpected ZeroTermsQuery: " <> show q)
2841
2845
2842instance ToJSON MatchQueryType where
2846instance ToJSON MatchQueryType where
2843− toJSON MatchPhrase = "phrase"
2847+ toJSON MatchPhrase = "phrase"
2844 toJSON MatchPhrasePrefix = "phrase_prefix"
2848 toJSON MatchPhrasePrefix = "phrase_prefix"
2845
2849
2846instance FromJSON MatchQueryType where
2850instance FromJSON MatchQueryType where
@@ -2974,7 +2978,7 @@ instance FromJSON IndexSettingsSummary where
2974 <*> (fmap (filter (not . redundant)) . parseSettings =<< o' .: "settings")
2978 <*> (fmap (filter (not . redundant)) . parseSettings =<< o' .: "settings")
2975 _ -> fail "Expected single-key object with index name"
2979 _ -> fail "Expected single-key object with index name"
2976 redundant (NumberOfReplicas _) = True
2980 redundant (NumberOfReplicas _) = True
2977− redundant _ = False
2981+ redundant _ = False
2978
2982
2979-- | For some reason in several settings APIs, all leaf values get returned
2983-- | For some reason in several settings APIs, all leaf values get returned
2980-- as strings. This function attepmts to recover from this for all
2984-- as strings. This function attepmts to recover from this for all
@@ -2984,7 +2988,7 @@ unStringlyTypeJSON (String "true") = Bool True
2984unStringlyTypeJSON (String "false") = Bool False
2988unStringlyTypeJSON (String "false") = Bool False
2985unStringlyTypeJSON (String "null") = Null
2989unStringlyTypeJSON (String "null") = Null
2986unStringlyTypeJSON v@(String t) = case readMay (T.unpack t) of
2990unStringlyTypeJSON v@(String t) = case readMay (T.unpack t) of
2987− Just n -> Number n
2991+ Just n -> Number n
2988 Nothing -> v
2992 Nothing -> v
2989unStringlyTypeJSON v = v
2993unStringlyTypeJSON v = v
2990
2994
@@ -3001,7 +3005,7 @@ parseSettings o = do
3001 return (catMaybes parses)
3005 return (catMaybes parses)
3002
3006
3003oPath :: ToJSON a => NonEmpty Text -> a -> Value
3007oPath :: ToJSON a => NonEmpty Text -> a -> Value
3004−oPath (k :| []) v = object [k .= v]
3008+oPath (k :| []) v = object [k .= v]
3005oPath (k:| (h:t)) v = object [k .= oPath (h :| t) v]
3009oPath (k:| (h:t)) v = object [k .= oPath (h :| t) v]
3006
3010
3007attrFilterJSON :: NonEmpty NodeAttrFilter -> Value
3011attrFilterJSON :: NonEmpty NodeAttrFilter -> Value
@@ -3011,12 +3015,12 @@ attrFilterJSON fs = object [ n .= T.intercalate "," (toList vs)
3011parseAttrFilter :: Value -> Parser (NonEmpty NodeAttrFilter)
3015parseAttrFilter :: Value -> Parser (NonEmpty NodeAttrFilter)
3012parseAttrFilter = withObject "NonEmpty NodeAttrFilter" parse
3016parseAttrFilter = withObject "NonEmpty NodeAttrFilter" parse
3013 where parse o = case HM.toList o of
3017 where parse o = case HM.toList o of
3014− [] -> fail "Expected non-empty list of NodeAttrFilters"
3018+ [] -> fail "Expected non-empty list of NodeAttrFilters"
3015 x:xs -> DT.mapM (uncurry parse') (x :| xs)
3019 x:xs -> DT.mapM (uncurry parse') (x :| xs)
3016 parse' n = withText "Text" $ \t ->
3020 parse' n = withText "Text" $ \t ->
3017 case T.splitOn "," t of
3021 case T.splitOn "," t of
3018 fv:fvs -> return (NodeAttrFilter (NodeAttrName n) (fv :| fvs))
3022 fv:fvs -> return (NodeAttrFilter (NodeAttrName n) (fv :| fvs))
3019− [] -> fail "Expected non-empty list of filter values"
3023+ [] -> fail "Expected non-empty list of filter values"
3020
3024
3021instance ToJSON ReplicaBounds where
3025instance ToJSON ReplicaBounds where
3022 toJSON (ReplicasBounded a b) = String (showText a <> "-" <> showText b)
3026 toJSON (ReplicasBounded a b) = String (showText a <> "-" <> showText b)
@@ -3070,12 +3074,12 @@ instance ToJSON FSType where
3070
3074
3071instance FromJSON FSType where
3075instance FromJSON FSType where
3072 parseJSON = withText "FSType" parse
3076 parseJSON = withText "FSType" parse
3073− where parse "simple" = pure FSSimple
3077+ where parse "simple" = pure FSSimple
3074 parse "buffered" = pure FSBuffered
3078 parse "buffered" = pure FSBuffered
3075− parse t = fail ("Invalid FSType: " <> show t)
3079+ parse t = fail ("Invalid FSType: " <> show t)
3076
3080
3077instance ToJSON CompoundFormat where
3081instance ToJSON CompoundFormat where
3078− toJSON (CompoundFileFormat x) = Bool x
3082+ toJSON (CompoundFileFormat x) = Bool x
3079 toJSON (MergeSegmentVsTotalIndex x) = toJSON x
3083 toJSON (MergeSegmentVsTotalIndex x) = toJSON x
3080
3084
3081instance FromJSON CompoundFormat where
3085instance FromJSON CompoundFormat where
@@ -3193,7 +3197,7 @@ instance ToJSON Search where
3193 , "track_scores" .= sTrackSortScores
3197 , "track_scores" .= sTrackSortScores
3194 , "fields" .= sFields
3198 , "fields" .= sFields
3195 , "_source" .= sSource]
3199 , "_source" .= sSource]
3196−
3200+
3197 where query' = case sFilter of
3201 where query' = case sFilter of
3198 Nothing -> mquery
3202 Nothing -> mquery
3199 Just x -> Just . QueryBoolQuery $ mkBoolQuery (maybeToList mquery) [x] [] []
3203 Just x -> Just . QueryBoolQuery $ mkBoolQuery (maybeToList mquery) [x] [] []
@@ -3334,8 +3338,8 @@ instance ToJSON SortMode where
3334
3338
3335
3339
3336instance ToJSON Missing where
3340instance ToJSON Missing where
3337− toJSON LastMissing = String "_last"
3341+ toJSON LastMissing = String "_last"
3338− toJSON FirstMissing = String "_first"
3342+ toJSON FirstMissing = String "_first"
3339 toJSON (CustomMissing txt) = String txt
3343 toJSON (CustomMissing txt) = String txt
3340
3344
3341
3345
@@ -3351,7 +3355,7 @@ instance FromJSON ScoreType where
3351 parse "avg" = pure ScoreTypeAvg
3355 parse "avg" = pure ScoreTypeAvg
3352 parse "sum" = pure ScoreTypeSum
3356 parse "sum" = pure ScoreTypeSum
3353 parse "none" = pure ScoreTypeNone
3357 parse "none" = pure ScoreTypeNone
3354− parse t = fail ("Unexpected ScoreType: " <> show t)
3358+ parse t = fail ("Unexpected ScoreType: " <> show t)
3355
3359
3356instance ToJSON Distance where
3360instance ToJSON Distance where
3357 toJSON (Distance dCoefficient dUnit) =
3361 toJSON (Distance dCoefficient dUnit) =
@@ -3369,7 +3373,7 @@ instance FromJSON Distance where
3369 validForNumber '-' = True
3373 validForNumber '-' = True
3370 validForNumber '.' = True
3374 validForNumber '.' = True
3371 validForNumber 'e' = True
3375 validForNumber 'e' = True
3372− validForNumber c = isNumber c
3376+ validForNumber c = isNumber c
3373 parseCoeff "" = fail "Empty string cannot be parsed as number"
3377 parseCoeff "" = fail "Empty string cannot be parsed as number"
3374 parseCoeff s = return (read (T.unpack s))
3378 parseCoeff s = return (read (T.unpack s))
3375
3379
@@ -3396,7 +3400,7 @@ instance FromJSON DistanceUnit where
3396 parse "cm" = pure Centimeters
3400 parse "cm" = pure Centimeters
3397 parse "mm" = pure Millimeters
3401 parse "mm" = pure Millimeters
3398 parse "nmi" = pure NauticalMiles
3402 parse "nmi" = pure NauticalMiles
3399− parse u = fail ("Unrecognized DistanceUnit: " <> show u)
3403+ parse u = fail ("Unrecognized DistanceUnit: " <> show u)
3400
3404
3401instance ToJSON DistanceType where
3405instance ToJSON DistanceType where
3402 toJSON Arc = String "arc"
3406 toJSON Arc = String "arc"
@@ -3405,21 +3409,21 @@ instance ToJSON DistanceType where
3405
3409
3406instance FromJSON DistanceType where
3410instance FromJSON DistanceType where
3407 parseJSON = withText "DistanceType" parse
3411 parseJSON = withText "DistanceType" parse
3408− where parse "arc" = pure Arc
3412+ where parse "arc" = pure Arc
3409 parse "sloppy_arc" = pure SloppyArc
3413 parse "sloppy_arc" = pure SloppyArc
3410− parse "plane" = pure Plane
3414+ parse "plane" = pure Plane
3411− parse t = fail ("Unrecognized DistanceType: " <> show t)
3415+ parse t = fail ("Unrecognized DistanceType: " <> show t)
3412
3416
3413
3417
3414instance ToJSON OptimizeBbox where
3418instance ToJSON OptimizeBbox where
3415− toJSON NoOptimizeBbox = String "none"
3419+ toJSON NoOptimizeBbox = String "none"
3416 toJSON (OptimizeGeoFilterType gft) = toJSON gft
3420 toJSON (OptimizeGeoFilterType gft) = toJSON gft
3417
3421
3418instance FromJSON OptimizeBbox where
3422instance FromJSON OptimizeBbox where
3419 parseJSON v = withText "NoOptimizeBbox" parseNoOptimize v
3423 parseJSON v = withText "NoOptimizeBbox" parseNoOptimize v
3420 <|> parseOptimize v
3424 <|> parseOptimize v
3421 where parseNoOptimize "none" = pure NoOptimizeBbox
3425 where parseNoOptimize "none" = pure NoOptimizeBbox
3422− parseNoOptimize _ = mzero
3426+ parseNoOptimize _ = mzero
3423 parseOptimize = fmap OptimizeGeoFilterType . parseJSON
3427 parseOptimize = fmap OptimizeGeoFilterType . parseJSON
3424
3428
3425instance ToJSON GeoBoundingBoxConstraint where
3429instance ToJSON GeoBoundingBoxConstraint where
@@ -4202,7 +4206,7 @@ instance SnapshotRepo FsSnapshotRepo where
4202
4206
4203parseRepo :: Parser a -> Either SnapshotRepoConversionError a
4207parseRepo :: Parser a -> Either SnapshotRepoConversionError a
4204parseRepo parser = case parseEither (const parser) () of
4208parseRepo parser = case parseEither (const parser) () of
4205− Left e -> Left (OtherRepoConversionError (T.pack e))
4209+ Left e -> Left (OtherRepoConversionError (T.pack e))
4206 Right a -> Right a
4210 Right a -> Right a
4207
4211
4208
4212
@@ -4683,7 +4687,7 @@ instance FromJSON NodeProcessStats where
4683 <*> o .: "open_file_descriptors"
4687 <*> o .: "open_file_descriptors"
4684 <*> o .: "max_file_descriptors"
4688 <*> o .: "max_file_descriptors"
4685 <*> cpu .: "percent"
4689 <*> cpu .: "percent"
4686− <*> (unMS <$> cpu .: "total_in_millis")
4690+ <*> (unMS <$> cpu .: "total_in_millis")
4687 <*> mem .: "total_virtual_in_bytes"
4691 <*> mem .: "total_virtual_in_bytes"
4688
4692
4689instance FromJSON NodeOSStats where
4693instance FromJSON NodeOSStats where
@@ -4720,7 +4724,7 @@ instance FromJSON NodeIndicesStats where
4720 where
4724 where
4721 parse o = do
4725 parse o = do
4722 let (.::) mv k = case mv of
4726 let (.::) mv k = case mv of
4723− Just v -> Just <$> v .: k
4727+ Just v -> Just <$> v .: k
4724 Nothing -> pure Nothing
4728 Nothing -> pure Nothing
4725 mRecovery <- o .:? "recovery"
4729 mRecovery <- o .:? "recovery"
4726 mQueryCache <- o .:? "query_cache"
4730 mQueryCache <- o .:? "query_cache"
@@ -4965,8 +4969,8 @@ parseStringInterval s = case span isNumber s of
4965 ("", _) -> fail "Invalid interval"
4969 ("", _) -> fail "Invalid interval"
4966 (nS, unitS) -> case (readMay nS, readMay unitS) of
4970 (nS, unitS) -> case (readMay nS, readMay unitS) of
4967 (Just n, Just unit) -> return (fromInteger (n * unitNDT unit))
4971 (Just n, Just unit) -> return (fromInteger (n * unitNDT unit))
4968− (Nothing, _) -> fail "Invalid interval number"
4972+ (Nothing, _) -> fail "Invalid interval number"
4969− (_, Nothing) -> fail "Invalid interval unit"
4973+ (_, Nothing) -> fail "Invalid interval unit"
4970 where
4974 where
4971 unitNDT Seconds = 1
4975 unitNDT Seconds = 1
4972 unitNDT Minutes = 60
4976 unitNDT Minutes = 60
@@ -4985,8 +4989,8 @@ instance FromJSON ThreadPoolSize where
4985 parseAsString = withText "ThreadPoolSize" $ \t ->
4989 parseAsString = withText "ThreadPoolSize" $ \t ->
4986 case first (readMay . T.unpack) (T.span isNumber t) of
4990 case first (readMay . T.unpack) (T.span isNumber t) of
4987 (Just n, "k") -> return (ThreadPoolBounded (n * 1000))
4991 (Just n, "k") -> return (ThreadPoolBounded (n * 1000))
4988− (Just n, "") -> return (ThreadPoolBounded n)
4992+ (Just n, "") -> return (ThreadPoolBounded n)
4989− _ -> fail ("Invalid thread pool size " <> T.unpack t)
4993+ _ -> fail ("Invalid thread pool size " <> T.unpack t)
4990
4994
4991instance FromJSON ThreadPoolType where
4995instance FromJSON ThreadPoolType where
4992 parseJSON = withText "ThreadPoolType" parse
4996 parseJSON = withText "ThreadPoolType" parse
@@ -5001,10 +5005,10 @@ instance FromJSON NodeTransportInfo where
5001 where
5005 where
5002 parse o = NodeTransportInfo <$> (maybe (return mempty) parseProfiles =<< o .:? "profiles")
5006 parse o = NodeTransportInfo <$> (maybe (return mempty) parseProfiles =<< o .:? "profiles")
5003 <*> parseJSON (Object o)
5007 <*> parseJSON (Object o)
5004− parseProfiles (Object o) | HM.null o = return []
5008+ parseProfiles (Object o) | HM.null o = return []
5005 parseProfiles v@(Array _) = parseJSON v
5009 parseProfiles v@(Array _) = parseJSON v
5006− parseProfiles Null = return []
5010+ parseProfiles Null = return []
5007− parseProfiles _ = fail "Could not parse profiles"
5011+ parseProfiles _ = fail "Could not parse profiles"
5008
5012
5009instance FromJSON NodeNetworkInfo where
5013instance FromJSON NodeNetworkInfo where
5010 parseJSON = withObject "NodeNetworkInfo" parse
5014 parseJSON = withObject "NodeNetworkInfo" parse
@@ -5025,4 +5029,4 @@ newtype MaybeNA a = MaybeNA { unMaybeNA :: Maybe a }
5025
5029
5026instance FromJSON a => FromJSON (MaybeNA a) where
5030instance FromJSON a => FromJSON (MaybeNA a) where
5027 parseJSON (String "NA") = pure $ MaybeNA Nothing
5031 parseJSON (String "NA") = pure $ MaybeNA Nothing
5028− parseJSON o = MaybeNA . Just <$> parseJSON o
5032+ parseJSON o = MaybeNA . Just <$> parseJSON o