git.iko.soy/typeable/bloodhound
on master help sign in
WIP
5b6c05fMichael Xavier
bloodhound.cabal+11−1
@@ -46,11 +46,21 @@ library
46 Database.V5.Bloodhound.Internal.Sort
46 Database.V5.Bloodhound.Internal.Sort
47 Database.V5.Bloodhound.Internal.StringlyTyped
47 Database.V5.Bloodhound.Internal.StringlyTyped
48 Database.V5.Bloodhound.Internal.Suggest
48 Database.V5.Bloodhound.Internal.Suggest
49+
49 Database.V1.Bloodhound
50 Database.V1.Bloodhound
50 Database.V1.Bloodhound.Client
51 Database.V1.Bloodhound.Client
51 Database.V1.Bloodhound.Types
52 Database.V1.Bloodhound.Types
52 Database.V1.Bloodhound.Types.Class
53 Database.V1.Bloodhound.Types.Class
54+
55+ -- Database.V1.Bloodhound.Internal.Aggregation
56+ -- Database.V1.Bloodhound.Internal.Analysis
53− Database.V1.Bloodhound.Types.Internal
57+ -- Database.V1.Bloodhound.Internal.Client
58+ -- Database.V1.Bloodhound.Internal.Highlight
59+ -- Database.V1.Bloodhound.Internal.Newtypes
60+ -- Database.V1.Bloodhound.Internal.Query
61+ -- Database.V1.Bloodhound.Internal.Sort
62+ Database.V1.Bloodhound.Internal.StringlyTyped
63+ -- Database.V1.Bloodhound.Internal.Suggest
54 other-modules: Bloodhound.Import
64 other-modules: Bloodhound.Import
55 Database.Bloodhound.Common.Script
65 Database.Bloodhound.Common.Script
56 hs-source-dirs: src
66 hs-source-dirs: src
src/Database/V1/Bloodhound/Internal/Aggregation.hsnew file+145
@@ -0,0 +1,145 @@
1+module Database.V1.Bloodhound.Internal.Aggregation where
2+
3+import Bloodhound.Import
4+
5+import Data.Text
6+import qualified Data.Text as T
7+
8+
9+type Aggregations = M.Map Text Aggregation
10+
11+emptyAggregations :: Aggregations
12+emptyAggregations = M.empty
13+
14+mkAggregations :: Text -> Aggregation -> Aggregations
15+mkAggregations name aggregation = M.insert name aggregation emptyAggregations
16+
17+data Aggregation = TermsAgg TermsAggregation
18+ | CardinalityAgg CardinalityAggregation
19+ | DateHistogramAgg DateHistogramAggregation
20+ | ValueCountAgg ValueCountAggregation
21+ | FilterAgg FilterAggregation
22+ | DateRangeAgg DateRangeAggregation
23+ | MissingAgg MissingAggregation
24+ | TopHitsAgg TopHitsAggregation
25+ deriving (Eq, Read, Show, Generic, Typeable)
26+
27+
28+instance ToJSON Aggregation where
29+ toJSON (TermsAgg (TermsAggregation term include exclude order minDocCount size shardSize collectMode executionHint termAggs)) =
30+ omitNulls ["terms" .= omitNulls [ toJSON' term,
31+ "include" .= include,
32+ "exclude" .= exclude,
33+ "order" .= order,
34+ "min_doc_count" .= minDocCount,
35+ "size" .= size,
36+ "shard_size" .= shardSize,
37+ "collect_mode" .= collectMode,
38+ "execution_hint" .= executionHint
39+ ],
40+ "aggs" .= termAggs ]
41+ where
42+ toJSON' x = case x of { Left y -> "field" .= y; Right y -> "script" .= y }
43+
44+ toJSON (CardinalityAgg (CardinalityAggregation field precisionThreshold)) =
45+ object ["cardinality" .= omitNulls [ "field" .= field,
46+ "precisionThreshold" .= precisionThreshold
47+ ]
48+ ]
49+
50+ toJSON (DateHistogramAgg (DateHistogramAggregation field interval format preZone postZone preOffset postOffset dateHistoAggs)) =
51+ omitNulls ["date_histogram" .= omitNulls [ "field" .= field,
52+ "interval" .= interval,
53+ "format" .= format,
54+ "pre_zone" .= preZone,
55+ "post_zone" .= postZone,
56+ "pre_offset" .= preOffset,
57+ "post_offset" .= postOffset
58+ ],
59+ "aggs" .= dateHistoAggs ]
60+ toJSON (ValueCountAgg a) = object ["value_count" .= v]
61+ where v = case a of
62+ (FieldValueCount (FieldName n)) -> object ["field" .= n]
63+ (ScriptValueCount (Script s)) -> object ["script" .= s]
64+ toJSON (FilterAgg (FilterAggregation filt ags)) =
65+ omitNulls [ "filter" .= filt
66+ , "aggs" .= ags]
67+ toJSON (DateRangeAgg a) = object [ "date_range" .= a
68+ ]
69+ toJSON (MissingAgg (MissingAggregation{..})) =
70+ object ["missing" .= object ["field" .= maField]]
71+
72+ toJSON (TopHitsAgg (TopHitsAggregation mfrom msize msort)) =
73+ omitNulls ["top_hits" .= omitNulls [ "size" .= msize
74+ , "from" .= mfrom
75+ , "sort" .= msort
76+ ]
77+ ]
78+
79+data TopHitsAggregation = TopHitsAggregation
80+ { taFrom :: Maybe From
81+ , taSize :: Maybe Size
82+ , taSort :: Maybe Sort
83+ } deriving (Eq, Read, Show)
84+
85+data MissingAggregation = MissingAggregation
86+ { maField :: Text
87+ } deriving (Eq, Read, Show, Generic, Typeable)
88+
89+data TermsAggregation = TermsAggregation { term :: Either Text Text
90+ , termInclude :: Maybe TermInclusion
91+ , termExclude :: Maybe TermInclusion
92+ , termOrder :: Maybe TermOrder
93+ , termMinDocCount :: Maybe Int
94+ , termSize :: Maybe Int
95+ , termShardSize :: Maybe Int
96+ , termCollectMode :: Maybe CollectionMode
97+ , termExecutionHint :: Maybe ExecutionHint
98+ , termAggs :: Maybe Aggregations
99+ } deriving (Eq, Read, Show, Generic, Typeable)
100+
101+data CardinalityAggregation = CardinalityAggregation { cardinalityField :: FieldName,
102+ precisionThreshold :: Maybe Int
103+ } deriving (Eq, Read, Show, Generic, Typeable)
104+
105+data DateHistogramAggregation = DateHistogramAggregation { dateField :: FieldName
106+ , dateInterval :: Interval
107+ , dateFormat :: Maybe Text
108+ -- pre and post deprecated in 1.5
109+ , datePreZone :: Maybe Text
110+ , datePostZone :: Maybe Text
111+ , datePreOffset :: Maybe Text
112+ , datePostOffset :: Maybe Text
113+ , dateAggs :: Maybe Aggregations
114+ } deriving (Eq, Read, Show, Generic, Typeable)
115+
116+
117+data DateRangeAggregation = DateRangeAggregation { draField :: FieldName
118+ , draFormat :: Maybe Text
119+ , draRanges :: NonEmpty DateRangeAggRange
120+ } deriving (Eq, Read, Show, Generic, Typeable)
121+
122+data DateRangeAggRange = DateRangeFrom DateMathExpr
123+ | DateRangeTo DateMathExpr
124+ | DateRangeFromAndTo DateMathExpr DateMathExpr deriving (Eq, Read, Show, Generic, Typeable)
125+
126+-- | See <https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-valuecount-aggregation.html> for more information.
127+data ValueCountAggregation = FieldValueCount FieldName
128+ | ScriptValueCount Script deriving (Eq, Read, Show, Generic, Typeable)
129+
130+-- | 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.
131+data FilterAggregation = FilterAggregation { faFilter :: Filter
132+ , faAggs :: Maybe Aggregations} deriving (Eq, Read, Show, Generic, Typeable)
133+
134+mkTermsAggregation :: Text -> TermsAggregation
135+mkTermsAggregation t = TermsAggregation (Left t) Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
136+
137+mkTermsScriptAggregation :: Text -> TermsAggregation
138+mkTermsScriptAggregation t = TermsAggregation (Right t) Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
139+
140+mkDateHistogram :: FieldName -> Interval -> DateHistogramAggregation
141+mkDateHistogram t i = DateHistogramAggregation t i Nothing Nothing Nothing Nothing Nothing Nothing
142+
143+mkCardinalityAggregation :: FieldName -> CardinalityAggregation
144+mkCardinalityAggregation t = CardinalityAggregation t Nothing
145+
src/Database/V1/Bloodhound/Internal/Client.hsnew file+237
@@ -0,0 +1,237 @@
1+module Database.V1.Bloodhound.Internal.Client where
2+
3+
4+import Control.Applicative as A
5+import Control.Monad.Reader
6+import Data.Aeson
7+import Data.Text (Text)
8+import Data.Typeable (Typeable)
9+import GHC.Generics (Generic)
10+import Network.HTTP.Client
11+
12+
13+{-| Common environment for Elasticsearch calls. Connections will be
14+ pipelined according to the provided HTTP connection manager.
15+-}
16+data BHEnv = BHEnv { bhServer :: Server
17+ , bhManager :: Manager
18+ , bhRequestHook :: Request -> IO Request
19+ -- ^ Low-level hook that is run before every request is sent. Used to implement custom authentication strategies. Defaults to 'return' with 'mkBHEnv'.
20+ }
21+
22+instance (Functor m, Applicative m, MonadIO m) => MonadBH (ReaderT BHEnv m) where
23+ getBHEnv = ask
24+
25+{-| 'Server' is used with the client functions to point at the ES instance
26+-}
27+newtype Server = Server Text deriving (Eq, Show, Generic, Typeable, FromJSON)
28+
29+{-| All API calls to Elasticsearch operate within
30+ MonadBH
31+ . The idea is that it can be easily embedded in your
32+ own monad transformer stack. A default instance for a ReaderT and
33+ alias 'BH' is provided for the simple case.
34+-}
35+class (Functor m, A.Applicative m, MonadIO m) => MonadBH m where
36+ getBHEnv :: m BHEnv
37+
38+-- $setup
39+-- >>> :set -XOverloadedStrings
40+-- >>> import Data.Aeson
41+-- >>> import Database.V1.Bloodhound
42+-- >>> let testServer = (Server "http://localhost:9200")
43+-- >>> let testIndex = IndexName "twitter"
44+-- >>> let testMapping = MappingName "tweet"
45+-- >>> let defaultIndexSettings = IndexSettings (ShardCount 3) (ReplicaCount 2)
46+
47+-- defaultIndexSettings is exported by Database.Bloodhound as well
48+-- no trailing slashes in servers, library handles building the path.
49+
50+-- | Create a 'BHEnv' with all optional fields defaulted. HTTP hook
51+-- will be a noop. You can use the exported fields to customize it further, e.g.:
52+--
53+-- >> (mkBHEnv myServer myManager) { bhRequestHook = customHook }
54+mkBHEnv :: Server -> Manager -> BHEnv
55+mkBHEnv s m = BHEnv s m return
56+
57+newtype BH m a = BH {
58+ unBH :: ReaderT BHEnv m a
59+ } deriving ( Functor
60+ , A.Applicative
61+ , Monad
62+ , MonadIO
63+ , MonadState s
64+ , MonadWriter w
65+ , MonadError e
66+ , Alternative
67+ , MonadPlus
68+ , MonadFix
69+ , MonadThrow
70+ , MonadCatch
71+ , MonadMask)
72+
73+instance MonadTrans BH where
74+ lift = BH . lift
75+
76+instance (MonadReader r m) => MonadReader r (BH m) where
77+ ask = lift ask
78+ local f (BH (ReaderT m)) = BH $ ReaderT $ \r ->
79+ local f (m r)
80+
81+instance (Functor m, Applicative m, MonadIO m) => MonadBH (BH m) where
82+ getBHEnv = BH getBHEnv
83+
84+runBH :: BHEnv -> BH m a -> m a
85+runBH e f = runReaderT (unBH f) e
86+
87+{-| 'Version' is embedded in 'Status' -}
88+data Version = Version { number :: VersionNumber
89+ , build_hash :: BuildHash
90+ , build_timestamp :: UTCTime
91+ , build_snapshot :: Bool
92+ , lucene_version :: VersionNumber } deriving (Eq, Read, Show, Generic, Typeable)
93+
94+-- | Traditional software versioning number
95+newtype VersionNumber = VersionNumber { versionNumber :: Vers.Version
96+ } deriving (Eq, Read, Show, Generic, Typeable, Ord)
97+
98+{-| 'Status' is a data type for describing the JSON body returned by
99+ Elasticsearch when you query its status. This was deprecated in 1.2.0.
100+
101+ <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-status.html#indices-status>
102+-}
103+
104+data Status = Status { ok :: Maybe Bool
105+ , status :: Int
106+ , name :: Text
107+ , version :: Version
108+ , tagline :: Text } deriving (Eq, Read, Show, Generic)
109+
110+{-| 'IndexSettings' is used to configure the shards and replicas when you create
111+ an Elasticsearch Index.
112+
113+ <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-create-index.html>
114+-}
115+
116+data IndexSettings =
117+ IndexSettings { indexShards :: ShardCount
118+ , indexReplicas :: ReplicaCount } deriving (Eq, Read, Show, Generic, Typeable)
119+
120+{-| 'defaultIndexSettings' is an 'IndexSettings' with 3 shards and 2 replicas. -}
121+defaultIndexSettings :: IndexSettings
122+defaultIndexSettings = IndexSettings (ShardCount 3) (ReplicaCount 2)
123+
124+
125+{-| 'IndexOptimizationSettings' is used to configure index optimization. See
126+ <https://www.elastic.co/guide/en/elasticsearch/reference/1.7/indices-optimize.html>
127+ for more info.
128+-}
129+data IndexOptimizationSettings =
130+ IndexOptimizationSettings { maxNumSegments :: Maybe Int
131+ -- ^ 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.
132+ , onlyExpungeDeletes :: Bool
133+ -- ^ 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.
134+ , flushAfterOptimize :: Bool
135+ -- ^ Should a flush be performed after the optimize.
136+ } deriving (Eq, Show, Generic, Typeable)
137+
138+
139+{-| 'defaultIndexOptimizationSettings' implements the default settings that
140+ ElasticSearch uses for index optimization. 'maxNumSegments' is Nothing,
141+ 'onlyExpungeDeletes' is False, and flushAfterOptimize is True.
142+-}
143+defaultIndexOptimizationSettings :: IndexOptimizationSettings
144+defaultIndexOptimizationSettings = IndexOptimizationSettings Nothing False True
145+
146+{-| 'UpdatableIndexSetting' are settings which may be updated after an index is created.
147+
148+ <https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html>
149+-}
150+data UpdatableIndexSetting = NumberOfReplicas ReplicaCount
151+ -- ^ The number of replicas each shard has.
152+ | AutoExpandReplicas ReplicaBounds
153+ | BlocksReadOnly Bool
154+ -- ^ Set to True to have the index read only. False to allow writes and metadata changes.
155+ | BlocksRead Bool
156+ -- ^ Set to True to disable read operations against the index.
157+ | BlocksWrite Bool
158+ -- ^ Set to True to disable write operations against the index.
159+ | BlocksMetaData Bool
160+ -- ^ Set to True to disable metadata operations against the index.
161+ | RefreshInterval NominalDiffTime
162+ -- ^ The async refresh interval of a shard
163+ | IndexConcurrency Int
164+ | FailOnMergeFailure Bool
165+ | TranslogFlushThresholdOps Int
166+ -- ^ When to flush on operations.
167+ | TranslogFlushThresholdSize Bytes
168+ -- ^ When to flush based on translog (bytes) size.
169+ | TranslogFlushThresholdPeriod NominalDiffTime
170+ -- ^ When to flush based on a period of not flushing.
171+ | TranslogDisableFlush Bool
172+ -- ^ Disables flushing. Note, should be set for a short interval and then enabled.
173+ | CacheFilterMaxSize (Maybe Bytes)
174+ -- ^ The maximum size of filter cache (per segment in shard).
175+ | CacheFilterExpire (Maybe NominalDiffTime)
176+ -- ^ The expire after access time for filter cache.
177+ | GatewaySnapshotInterval NominalDiffTime
178+ -- ^ The gateway snapshot interval (only applies to shared gateways).
179+ | RoutingAllocationInclude (NonEmpty NodeAttrFilter)
180+ -- ^ A node matching any rule will be allowed to host shards from the index.
181+ | RoutingAllocationExclude (NonEmpty NodeAttrFilter)
182+ -- ^ A node matching any rule will NOT be allowed to host shards from the index.
183+ | RoutingAllocationRequire (NonEmpty NodeAttrFilter)
184+ -- ^ Only nodes matching all rules will be allowed to host shards from the index.
185+ | RoutingAllocationEnable AllocationPolicy
186+ -- ^ Enables shard allocation for a specific index.
187+ | RoutingAllocationShardsPerNode ShardCount
188+ -- ^ Controls the total number of shards (replicas and primaries) allowed to be allocated on a single node.
189+ | RecoveryInitialShards InitialShardCount
190+ -- ^ When using local gateway a particular shard is recovered only if there can be allocated quorum shards in the cluster.
191+ | GCDeletes NominalDiffTime
192+ | TTLDisablePurge Bool
193+ -- ^ Disables temporarily the purge of expired docs.
194+ | TranslogFSType FSType
195+ | IndexCompoundFormat CompoundFormat
196+ | IndexCompoundOnFlush Bool
197+ | WarmerEnabled Bool
198+ deriving (Eq, Show, Generic, Typeable)
199+
200+data AllocationPolicy = AllocAll
201+ -- ^ Allows shard allocation for all shards.
202+ | AllocPrimaries
203+ -- ^ Allows shard allocation only for primary shards.
204+ | AllocNewPrimaries
205+ -- ^ Allows shard allocation only for primary shards for new indices.
206+ | AllocNone
207+ -- ^ No shard allocation is allowed
208+ deriving (Eq, Read, Show, Generic, Typeable)
209+
210+data ReplicaBounds = ReplicasBounded Int Int
211+ | ReplicasLowerBounded Int
212+ | ReplicasUnbounded
213+ deriving (Eq, Read, Show, Generic, Typeable)
214+
215+-- | A measure of bytes used for various configurations. You may want
216+-- to use smart constructors like 'gigabytes' for larger values.
217+--
218+-- >>> gigabytes 9
219+-- Bytes 9000000000
220+--
221+-- >>> megabytes 9
222+-- Bytes 9000000
223+--
224+-- >>> kilobytes 9
225+-- Bytes 9000
226+newtype Bytes = Bytes Int deriving (Eq, Read, Show, Generic, Typeable, Ord, ToJSON, FromJSON)
227+
228+gigabytes :: Int -> Bytes
229+gigabytes n = megabytes (1000 * n)
230+
231+
232+megabytes :: Int -> Bytes
233+megabytes n = kilobytes (1000 * n)
234+
235+
236+kilobytes :: Int -> Bytes
237+kilobytes n = Bytes (1000 * n)
src/Database/V1/Bloodhound/Internal/StringlyTyped.hsnew file+1
@@ -0,0 +1 @@
1+module Database.V1.Bloodhound.Internal.StringlyTyped where
src/Database/V1/Bloodhound/Types.hs+53−383
@@ -378,250 +378,53 @@ module Database.V1.Bloodhound.Types
378 , EsPassword(..)
378 , EsPassword(..)
379 ) where
379 ) where
380
380
381−import Control.Applicative as A
381+import Control.Applicative as A
382−import Control.Arrow (first)
382+import Control.Arrow (first)
383import Control.Monad.Catch
383import Control.Monad.Catch
384import Control.Monad.Except
384import Control.Monad.Except
385−import Control.Monad.Reader (MonadReader (..),
385+import Control.Monad.Reader (MonadReader (..),
386− ReaderT (..))
386+ ReaderT (..))
387−import Control.Monad.State (MonadState)
387+import Control.Monad.State (MonadState)
388−import Control.Monad.Writer (MonadWriter)
388+import Control.Monad.Writer (MonadWriter)
389import Data.Aeson
389import Data.Aeson
390−import Data.Aeson.Types (Pair, Parser,
390+import Data.Aeson.Types (Pair, Parser,
391− emptyObject,
391+ emptyObject,
392− parseEither, parseMaybe,
392+ parseEither,
393+ parseMaybe,
393− typeMismatch)
394+ typeMismatch)
394−import qualified Data.ByteString.Lazy.Char8 as L
395+import qualified Data.ByteString.Lazy.Char8 as L
395import Data.Char
396import Data.Char
396−import Data.Hashable (Hashable)
397+import Data.Hashable (Hashable)
397−import qualified Data.HashMap.Strict as HM
398+import qualified Data.HashMap.Strict as HM
398−import Data.List (foldl', intercalate,
399+import Data.List (foldl', intercalate,
399− nub)
400+ nub)
400−import Data.List.NonEmpty (NonEmpty (..), toList)
401+import Data.List.NonEmpty (NonEmpty (..), toList)
401−import qualified Data.Map.Strict as M
402+import qualified Data.Map.Strict as M
402import Data.Maybe
403import Data.Maybe
403−import Data.Scientific (Scientific)
404+import Data.Scientific (Scientific)
404import Data.Semigroup
405import Data.Semigroup
405−import Data.Text (Text)
406+import Data.Text (Text)
406−import qualified Data.Text as T
407+import qualified Data.Text as T
407import Data.Time.Calendar
408import Data.Time.Calendar
408−import Data.Time.Clock (NominalDiffTime,
409+import Data.Time.Clock (NominalDiffTime,
409− UTCTime)
410+ UTCTime)
410import Data.Time.Clock.POSIX
411import Data.Time.Clock.POSIX
411−import qualified Data.Traversable as DT
412+import qualified Data.Traversable as DT
412−import Data.Typeable (Typeable)
413+import Data.Typeable (Typeable)
413−import qualified Data.Vector as V
414+import qualified Data.Vector as V
414−import qualified Data.Version as Vers
415+import qualified Data.Version as Vers
415import GHC.Enum
416import GHC.Enum
416−import GHC.Generics (Generic)
417+import GHC.Generics (Generic)
417import Network.HTTP.Client
418import Network.HTTP.Client
418−import qualified Network.HTTP.Types.Method as NHTM
419+import qualified Network.HTTP.Types.Method as NHTM
419−import qualified Text.ParserCombinators.ReadP as RP
420+import qualified Text.ParserCombinators.ReadP as RP
420−import qualified Text.Read as TR
421+import qualified Text.Read as TR
421
422
423+import Database.V1.Bloodhound.Internal.Client
422import Database.V1.Bloodhound.Types.Class
424import Database.V1.Bloodhound.Types.Class
423import Database.V1.Bloodhound.Types.Internal
425import Database.V1.Bloodhound.Types.Internal
424
426
425−-- $setup
426−-- >>> :set -XOverloadedStrings
427−-- >>> import Data.Aeson
428−-- >>> import Database.V1.Bloodhound
429−-- >>> let testServer = (Server "http://localhost:9200")
430−-- >>> let testIndex = IndexName "twitter"
431−-- >>> let testMapping = MappingName "tweet"
432−-- >>> let defaultIndexSettings = IndexSettings (ShardCount 3) (ReplicaCount 2)
433
427
434−-- defaultIndexSettings is exported by Database.Bloodhound as well
435−-- no trailing slashes in servers, library handles building the path.
436−
437−-- | Create a 'BHEnv' with all optional fields defaulted. HTTP hook
438−-- will be a noop. You can use the exported fields to customize it further, e.g.:
439−--
440−-- >> (mkBHEnv myServer myManager) { bhRequestHook = customHook }
441−mkBHEnv :: Server -> Manager -> BHEnv
442−mkBHEnv s m = BHEnv s m return
443−
444−newtype BH m a = BH {
445− unBH :: ReaderT BHEnv m a
446− } deriving ( Functor
447− , A.Applicative
448− , Monad
449− , MonadIO
450− , MonadState s
451− , MonadWriter w
452− , MonadError e
453− , Alternative
454− , MonadPlus
455− , MonadFix
456− , MonadThrow
457− , MonadCatch
458− , MonadMask)
459−
460−instance MonadTrans BH where
461− lift = BH . lift
462−
463−instance (MonadReader r m) => MonadReader r (BH m) where
464− ask = lift ask
465− local f (BH (ReaderT m)) = BH $ ReaderT $ \r ->
466− local f (m r)
467−
468−instance (Functor m, Applicative m, MonadIO m) => MonadBH (BH m) where
469− getBHEnv = BH getBHEnv
470−
471−runBH :: BHEnv -> BH m a -> m a
472−runBH e f = runReaderT (unBH f) e
473−
474−{-| 'Version' is embedded in 'Status' -}
475−data Version = Version { number :: VersionNumber
476− , build_hash :: BuildHash
477− , build_timestamp :: UTCTime
478− , build_snapshot :: Bool
479− , lucene_version :: VersionNumber } deriving (Eq, Read, Show, Generic, Typeable)
480−
481−-- | Traditional software versioning number
482−newtype VersionNumber = VersionNumber { versionNumber :: Vers.Version
483− } deriving (Eq, Read, Show, Generic, Typeable, Ord)
484−
485−{-| 'Status' is a data type for describing the JSON body returned by
486− Elasticsearch when you query its status. This was deprecated in 1.2.0.
487−
488− <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-status.html#indices-status>
489−-}
490−
491−data Status = Status { ok :: Maybe Bool
492− , status :: Int
493− , name :: Text
494− , version :: Version
495− , tagline :: Text } deriving (Eq, Read, Show, Generic)
496−
497−{-| 'IndexSettings' is used to configure the shards and replicas when you create
498− an Elasticsearch Index.
499−
500− <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-create-index.html>
501−-}
502−
503−data IndexSettings =
504− IndexSettings { indexShards :: ShardCount
505− , indexReplicas :: ReplicaCount } deriving (Eq, Read, Show, Generic, Typeable)
506−
507−{-| 'defaultIndexSettings' is an 'IndexSettings' with 3 shards and 2 replicas. -}
508−defaultIndexSettings :: IndexSettings
509−defaultIndexSettings = IndexSettings (ShardCount 3) (ReplicaCount 2)
510−
511−
512−{-| 'IndexOptimizationSettings' is used to configure index optimization. See
513− <https://www.elastic.co/guide/en/elasticsearch/reference/1.7/indices-optimize.html>
514− for more info.
515−-}
516−data IndexOptimizationSettings =
517− IndexOptimizationSettings { maxNumSegments :: Maybe Int
518− -- ^ 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.
519− , onlyExpungeDeletes :: Bool
520− -- ^ 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.
521− , flushAfterOptimize :: Bool
522− -- ^ Should a flush be performed after the optimize.
523− } deriving (Eq, Show, Generic, Typeable)
524−
525−
526−{-| 'defaultIndexOptimizationSettings' implements the default settings that
527− ElasticSearch uses for index optimization. 'maxNumSegments' is Nothing,
528− 'onlyExpungeDeletes' is False, and flushAfterOptimize is True.
529−-}
530−defaultIndexOptimizationSettings :: IndexOptimizationSettings
531−defaultIndexOptimizationSettings = IndexOptimizationSettings Nothing False True
532−
533−{-| 'UpdatableIndexSetting' are settings which may be updated after an index is created.
534−
535− <https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html>
536−-}
537−data UpdatableIndexSetting = NumberOfReplicas ReplicaCount
538− -- ^ The number of replicas each shard has.
539− | AutoExpandReplicas ReplicaBounds
540− | BlocksReadOnly Bool
541− -- ^ Set to True to have the index read only. False to allow writes and metadata changes.
542− | BlocksRead Bool
543− -- ^ Set to True to disable read operations against the index.
544− | BlocksWrite Bool
545− -- ^ Set to True to disable write operations against the index.
546− | BlocksMetaData Bool
547− -- ^ Set to True to disable metadata operations against the index.
548− | RefreshInterval NominalDiffTime
549− -- ^ The async refresh interval of a shard
550− | IndexConcurrency Int
551− | FailOnMergeFailure Bool
552− | TranslogFlushThresholdOps Int
553− -- ^ When to flush on operations.
554− | TranslogFlushThresholdSize Bytes
555− -- ^ When to flush based on translog (bytes) size.
556− | TranslogFlushThresholdPeriod NominalDiffTime
557− -- ^ When to flush based on a period of not flushing.
558− | TranslogDisableFlush Bool
559− -- ^ Disables flushing. Note, should be set for a short interval and then enabled.
560− | CacheFilterMaxSize (Maybe Bytes)
561− -- ^ The maximum size of filter cache (per segment in shard).
562− | CacheFilterExpire (Maybe NominalDiffTime)
563− -- ^ The expire after access time for filter cache.
564− | GatewaySnapshotInterval NominalDiffTime
565− -- ^ The gateway snapshot interval (only applies to shared gateways).
566− | RoutingAllocationInclude (NonEmpty NodeAttrFilter)
567− -- ^ A node matching any rule will be allowed to host shards from the index.
568− | RoutingAllocationExclude (NonEmpty NodeAttrFilter)
569− -- ^ A node matching any rule will NOT be allowed to host shards from the index.
570− | RoutingAllocationRequire (NonEmpty NodeAttrFilter)
571− -- ^ Only nodes matching all rules will be allowed to host shards from the index.
572− | RoutingAllocationEnable AllocationPolicy
573− -- ^ Enables shard allocation for a specific index.
574− | RoutingAllocationShardsPerNode ShardCount
575− -- ^ Controls the total number of shards (replicas and primaries) allowed to be allocated on a single node.
576− | RecoveryInitialShards InitialShardCount
577− -- ^ When using local gateway a particular shard is recovered only if there can be allocated quorum shards in the cluster.
578− | GCDeletes NominalDiffTime
579− | TTLDisablePurge Bool
580− -- ^ Disables temporarily the purge of expired docs.
581− | TranslogFSType FSType
582− | IndexCompoundFormat CompoundFormat
583− | IndexCompoundOnFlush Bool
584− | WarmerEnabled Bool
585− deriving (Eq, Show, Generic, Typeable)
586−
587−data AllocationPolicy = AllocAll
588− -- ^ Allows shard allocation for all shards.
589− | AllocPrimaries
590− -- ^ Allows shard allocation only for primary shards.
591− | AllocNewPrimaries
592− -- ^ Allows shard allocation only for primary shards for new indices.
593− | AllocNone
594− -- ^ No shard allocation is allowed
595− deriving (Eq, Read, Show, Generic, Typeable)
596−
597−data ReplicaBounds = ReplicasBounded Int Int
598− | ReplicasLowerBounded Int
599− | ReplicasUnbounded
600− deriving (Eq, Read, Show, Generic, Typeable)
601−
602−-- | A measure of bytes used for various configurations. You may want
603−-- to use smart constructors like 'gigabytes' for larger values.
604−--
605−-- >>> gigabytes 9
606−-- Bytes 9000000000
607−--
608−-- >>> megabytes 9
609−-- Bytes 9000000
610−--
611−-- >>> kilobytes 9
612−-- Bytes 9000
613−newtype Bytes = Bytes Int deriving (Eq, Read, Show, Generic, Typeable, Ord, ToJSON, FromJSON)
614−
615−gigabytes :: Int -> Bytes
616−gigabytes n = megabytes (1000 * n)
617−
618−
619−megabytes :: Int -> Bytes
620−megabytes n = kilobytes (1000 * n)
621−
622−
623−kilobytes :: Int -> Bytes
624−kilobytes n = Bytes (1000 * n)
625
428
626
429
627data FSType = FSSimple
430data FSType = FSSimple
@@ -1739,13 +1542,6 @@ readMay s = case reads s of
1739parseReadText :: Read a => Text -> Parser a
1542parseReadText :: Read a => Text -> Parser a
1740parseReadText = maybe mzero return . readMay . T.unpack
1543parseReadText = maybe mzero return . readMay . T.unpack
1741
1544
1742−type Aggregations = M.Map Text Aggregation
1743−
1744−emptyAggregations :: Aggregations
1745−emptyAggregations = M.empty
1746−
1747−mkAggregations :: Text -> Aggregation -> Aggregations
1748−mkAggregations name aggregation = M.insert name aggregation emptyAggregations
1749
1545
1750data TermOrder = TermOrder{ termSortField :: Text
1546data TermOrder = TermOrder{ termSortField :: Text
1751 , termSortOrder :: SortOrder } deriving (Eq, Read, Show, Generic, Typeable)
1547 , termSortOrder :: SortOrder } deriving (Eq, Read, Show, Generic, Typeable)
@@ -1778,62 +1574,6 @@ data Interval = Year
1778 | Second
1574 | Second
1779 | FractionalInterval Float TimeInterval deriving (Eq, Read, Show, Generic, Typeable)
1575 | FractionalInterval Float TimeInterval deriving (Eq, Read, Show, Generic, Typeable)
1780
1576
1781−data Aggregation = TermsAgg TermsAggregation
1782− | CardinalityAgg CardinalityAggregation
1783− | DateHistogramAgg DateHistogramAggregation
1784− | ValueCountAgg ValueCountAggregation
1785− | FilterAgg FilterAggregation
1786− | DateRangeAgg DateRangeAggregation
1787− | MissingAgg MissingAggregation
1788− | TopHitsAgg TopHitsAggregation
1789− deriving (Eq, Read, Show, Generic, Typeable)
1790−
1791−data TopHitsAggregation = TopHitsAggregation
1792− { taFrom :: Maybe From
1793− , taSize :: Maybe Size
1794− , taSort :: Maybe Sort
1795− } deriving (Eq, Read, Show)
1796−
1797−data MissingAggregation = MissingAggregation
1798− { maField :: Text
1799− } deriving (Eq, Read, Show, Generic, Typeable)
1800−
1801−data TermsAggregation = TermsAggregation { term :: Either Text Text
1802− , termInclude :: Maybe TermInclusion
1803− , termExclude :: Maybe TermInclusion
1804− , termOrder :: Maybe TermOrder
1805− , termMinDocCount :: Maybe Int
1806− , termSize :: Maybe Int
1807− , termShardSize :: Maybe Int
1808− , termCollectMode :: Maybe CollectionMode
1809− , termExecutionHint :: Maybe ExecutionHint
1810− , termAggs :: Maybe Aggregations
1811− } deriving (Eq, Read, Show, Generic, Typeable)
1812−
1813−data CardinalityAggregation = CardinalityAggregation { cardinalityField :: FieldName,
1814− precisionThreshold :: Maybe Int
1815− } deriving (Eq, Read, Show, Generic, Typeable)
1816−
1817−data DateHistogramAggregation = DateHistogramAggregation { dateField :: FieldName
1818− , dateInterval :: Interval
1819− , dateFormat :: Maybe Text
1820− -- pre and post deprecated in 1.5
1821− , datePreZone :: Maybe Text
1822− , datePostZone :: Maybe Text
1823− , datePreOffset :: Maybe Text
1824− , datePostOffset :: Maybe Text
1825− , dateAggs :: Maybe Aggregations
1826− } deriving (Eq, Read, Show, Generic, Typeable)
1827−
1828−
1829−data DateRangeAggregation = DateRangeAggregation { draField :: FieldName
1830− , draFormat :: Maybe Text
1831− , draRanges :: NonEmpty DateRangeAggRange
1832− } deriving (Eq, Read, Show, Generic, Typeable)
1833−
1834−data DateRangeAggRange = DateRangeFrom DateMathExpr
1835− | DateRangeTo DateMathExpr
1836− | DateRangeFromAndTo DateMathExpr DateMathExpr deriving (Eq, Read, Show, Generic, Typeable)
1837
1577
1838-- | See <https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math> for more information.
1578-- | See <https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math> for more information.
1839data DateMathExpr = DateMathExpr DateMathAnchor [DateMathModifier] deriving (Eq, Read, Show, Generic, Typeable)
1579data DateMathExpr = DateMathExpr DateMathAnchor [DateMathModifier] deriving (Eq, Read, Show, Generic, Typeable)
@@ -1855,26 +1595,6 @@ data DateMathUnit = DMYear
1855 | DMMinute
1595 | DMMinute
1856 | DMSecond deriving (Eq, Read, Show, Generic, Typeable)
1596 | DMSecond deriving (Eq, Read, Show, Generic, Typeable)
1857
1597
1858−-- | See <https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-valuecount-aggregation.html> for more information.
1859−data ValueCountAggregation = FieldValueCount FieldName
1860− | ScriptValueCount Script deriving (Eq, Read, Show, Generic, Typeable)
1861−
1862−-- | 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.
1863−data FilterAggregation = FilterAggregation { faFilter :: Filter
1864− , faAggs :: Maybe Aggregations} deriving (Eq, Read, Show, Generic, Typeable)
1865−
1866−mkTermsAggregation :: Text -> TermsAggregation
1867−mkTermsAggregation t = TermsAggregation (Left t) Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
1868−
1869−mkTermsScriptAggregation :: Text -> TermsAggregation
1870−mkTermsScriptAggregation t = TermsAggregation (Right t) Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
1871−
1872−mkDateHistogram :: FieldName -> Interval -> DateHistogramAggregation
1873−mkDateHistogram t i = DateHistogramAggregation t i Nothing Nothing Nothing Nothing Nothing Nothing
1874−
1875−mkCardinalityAggregation :: FieldName -> CardinalityAggregation
1876−mkCardinalityAggregation t = CardinalityAggregation t Nothing
1877−
1878instance ToJSON Version where
1598instance ToJSON Version where
1879 toJSON Version {..} = object ["number" .= number
1599 toJSON Version {..} = object ["number" .= number
1880 ,"build_hash" .= build_hash
1600 ,"build_hash" .= build_hash
@@ -1950,56 +1670,6 @@ instance Read TimeInterval where
1950 f 's' = return Seconds
1670 f 's' = return Seconds
1951 f _ = fail "TimeInterval expected one of w, d, h, m, s"
1671 f _ = fail "TimeInterval expected one of w, d, h, m, s"
1952
1672
1953−instance ToJSON Aggregation where
1954− toJSON (TermsAgg (TermsAggregation term include exclude order minDocCount size shardSize collectMode executionHint termAggs)) =
1955− omitNulls ["terms" .= omitNulls [ toJSON' term,
1956− "include" .= include,
1957− "exclude" .= exclude,
1958− "order" .= order,
1959− "min_doc_count" .= minDocCount,
1960− "size" .= size,
1961− "shard_size" .= shardSize,
1962− "collect_mode" .= collectMode,
1963− "execution_hint" .= executionHint
1964− ],
1965− "aggs" .= termAggs ]
1966− where
1967− toJSON' x = case x of { Left y -> "field" .= y; Right y -> "script" .= y }
1968−
1969− toJSON (CardinalityAgg (CardinalityAggregation field precisionThreshold)) =
1970− object ["cardinality" .= omitNulls [ "field" .= field,
1971− "precisionThreshold" .= precisionThreshold
1972− ]
1973− ]
1974−
1975− toJSON (DateHistogramAgg (DateHistogramAggregation field interval format preZone postZone preOffset postOffset dateHistoAggs)) =
1976− omitNulls ["date_histogram" .= omitNulls [ "field" .= field,
1977− "interval" .= interval,
1978− "format" .= format,
1979− "pre_zone" .= preZone,
1980− "post_zone" .= postZone,
1981− "pre_offset" .= preOffset,
1982− "post_offset" .= postOffset
1983− ],
1984− "aggs" .= dateHistoAggs ]
1985− toJSON (ValueCountAgg a) = object ["value_count" .= v]
1986− where v = case a of
1987− (FieldValueCount (FieldName n)) -> object ["field" .= n]
1988− (ScriptValueCount (Script s)) -> object ["script" .= s]
1989− toJSON (FilterAgg (FilterAggregation filt ags)) =
1990− omitNulls [ "filter" .= filt
1991− , "aggs" .= ags]
1992− toJSON (DateRangeAgg a) = object [ "date_range" .= a
1993− ]
1994− toJSON (MissingAgg (MissingAggregation{..})) =
1995− object ["missing" .= object ["field" .= maField]]
1996−
1997− toJSON (TopHitsAgg (TopHitsAggregation mfrom msize msort)) =
1998− omitNulls ["top_hits" .= omitNulls [ "size" .= msize
1999− , "from" .= mfrom
2000− , "sort" .= msort
2001− ]
2002− ]
2003
1673
2004instance ToJSON DateRangeAggregation where
1674instance ToJSON DateRangeAggregation where
2005 toJSON DateRangeAggregation {..} =
1675 toJSON DateRangeAggregation {..} =
@@ -5358,7 +5028,7 @@ instance FromJSON Suggest where
5358 let dropTextList = HM.toList $ HM.filterWithKey (\x _ -> x /= "text") o
5028 let dropTextList = HM.toList $ HM.filterWithKey (\x _ -> x /= "text") o
5359 suggestName' <- case dropTextList of
5029 suggestName' <- case dropTextList of
5360 [(x, _)] -> return x
5030 [(x, _)] -> return x
5361− _ -> fail "error parsing Suggest field name"
5031+ _ -> fail "error parsing Suggest field name"
5362 suggestType' <- o .: suggestName'
5032 suggestType' <- o .: suggestName'
5363 return $ Suggest suggestText' suggestName' suggestType'
5033 return $ Suggest suggestText' suggestName' suggestType'
5364 parseJSON x = typeMismatch "Suggest" x
5034 parseJSON x = typeMismatch "Suggest" x
@@ -5428,7 +5098,7 @@ mkPhraseSuggester fName =
5428 Nothing Nothing Nothing Nothing []
5098 Nothing Nothing Nothing Nothing []
5429
5099
5430data PhraseSuggesterHighlighter =
5100data PhraseSuggesterHighlighter =
5431− PhraseSuggesterHighlighter { phraseSuggesterHighlighterPreTag :: Text
5101+ PhraseSuggesterHighlighter { phraseSuggesterHighlighterPreTag :: Text
5432 , phraseSuggesterHighlighterPostTag :: Text
5102 , phraseSuggesterHighlighterPostTag :: Text
5433 }
5103 }
5434 deriving (Show, Generic, Eq, Read, Typeable)
5104 deriving (Show, Generic, Eq, Read, Typeable)
@@ -5469,9 +5139,9 @@ instance FromJSON PhraseSuggesterCollate where
5469 parseJSON x = typeMismatch "PhraseSuggesterCollate" x
5139 parseJSON x = typeMismatch "PhraseSuggesterCollate" x
5470
5140
5471data SuggestOptions =
5141data SuggestOptions =
5472− SuggestOptions { suggestOptionsText :: Text
5142+ SuggestOptions { suggestOptionsText :: Text
5473− , suggestOptionsScore :: Double
5143+ , suggestOptionsScore :: Double
5474− , suggestOptionsFreq :: Maybe Int
5144+ , suggestOptionsFreq :: Maybe Int
5475 , suggestOptionsHighlighted :: Maybe Text
5145 , suggestOptionsHighlighted :: Maybe Text
5476 }
5146 }
5477 deriving (Eq, Read, Show)
5147 deriving (Eq, Read, Show)
@@ -5485,9 +5155,9 @@ instance FromJSON SuggestOptions where
5485 <*> o .:? "highlighted"
5155 <*> o .:? "highlighted"
5486
5156
5487data SuggestResponse =
5157data SuggestResponse =
5488− SuggestResponse { suggestResponseText :: Text
5158+ SuggestResponse { suggestResponseText :: Text
5489− , suggestResponseOffset :: Int
5159+ , suggestResponseOffset :: Int
5490− , suggestResponseLength :: Int
5160+ , suggestResponseLength :: Int
5491 , suggestResponseOptions :: [SuggestOptions]
5161 , suggestResponseOptions :: [SuggestOptions]
5492 }
5162 }
5493 deriving (Eq, Read, Show)
5163 deriving (Eq, Read, Show)
@@ -5501,7 +5171,7 @@ instance FromJSON SuggestResponse where
5501 <*> o .: "options"
5171 <*> o .: "options"
5502
5172
5503data NamedSuggestionResponse =
5173data NamedSuggestionResponse =
5504− NamedSuggestionResponse { nsrName :: Text
5174+ NamedSuggestionResponse { nsrName :: Text
5505 , nsrResponses :: [SuggestResponse]
5175 , nsrResponses :: [SuggestResponse]
5506 }
5176 }
5507 deriving (Eq, Read, Show)
5177 deriving (Eq, Read, Show)
@@ -5524,7 +5194,7 @@ data DirectGeneratorSuggestModeTypes = DirectGeneratorSuggestModeMissing
5524instance ToJSON DirectGeneratorSuggestModeTypes where
5194instance ToJSON DirectGeneratorSuggestModeTypes where
5525 toJSON DirectGeneratorSuggestModeMissing = "missing"
5195 toJSON DirectGeneratorSuggestModeMissing = "missing"
5526 toJSON DirectGeneratorSuggestModePopular = "popular"
5196 toJSON DirectGeneratorSuggestModePopular = "popular"
5527− toJSON DirectGeneratorSuggestModeAlways = "always"
5197+ toJSON DirectGeneratorSuggestModeAlways = "always"
5528
5198
5529instance FromJSON DirectGeneratorSuggestModeTypes where
5199instance FromJSON DirectGeneratorSuggestModeTypes where
5530 parseJSON = withText "DirectGeneratorSuggestModeTypes" parse
5200 parseJSON = withText "DirectGeneratorSuggestModeTypes" parse
@@ -5534,17 +5204,17 @@ instance FromJSON DirectGeneratorSuggestModeTypes where
5534 parse f = fail ("Unexpected DirectGeneratorSuggestModeTypes: " <> show f)
5204 parse f = fail ("Unexpected DirectGeneratorSuggestModeTypes: " <> show f)
5535
5205
5536data DirectGenerators = DirectGenerators
5206data DirectGenerators = DirectGenerators
5537− { directGeneratorsField :: FieldName
5207+ { directGeneratorsField :: FieldName
5538− , directGeneratorsSize :: Maybe Int
5208+ , directGeneratorsSize :: Maybe Int
5539− , directGeneratorSuggestMode :: DirectGeneratorSuggestModeTypes
5209+ , directGeneratorSuggestMode :: DirectGeneratorSuggestModeTypes
5540− , directGeneratorMaxEdits :: Maybe Double
5210+ , directGeneratorMaxEdits :: Maybe Double
5541− , directGeneratorPrefixLength :: Maybe Int
5211+ , directGeneratorPrefixLength :: Maybe Int
5542− , directGeneratorMinWordLength :: Maybe Int
5212+ , directGeneratorMinWordLength :: Maybe Int
5543 , directGeneratorMaxInspections :: Maybe Int
5213 , directGeneratorMaxInspections :: Maybe Int
5544− , directGeneratorMinDocFreq :: Maybe Double
5214+ , directGeneratorMinDocFreq :: Maybe Double
5545− , directGeneratorMaxTermFreq :: Maybe Double
5215+ , directGeneratorMaxTermFreq :: Maybe Double
5546− , directGeneratorPreFilter :: Maybe Text
5216+ , directGeneratorPreFilter :: Maybe Text
5547− , directGeneratorPostFilter :: Maybe Text
5217+ , directGeneratorPostFilter :: Maybe Text
5548 }
5218 }
5549 deriving (Show, Eq, Read, Generic, Typeable)
5219 deriving (Show, Eq, Read, Generic, Typeable)
5550
5220
@@ -5579,4 +5249,4 @@ instance FromJSON DirectGenerators where
5579 <*> o .:? "post_filter"
5249 <*> o .:? "post_filter"
5580
5250
5581mkDirectGenerators :: FieldName -> DirectGenerators
5251mkDirectGenerators :: FieldName -> DirectGenerators
5582−mkDirectGenerators fn = DirectGenerators fn Nothing DirectGeneratorSuggestModeMissing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
5252+mkDirectGenerators fn = DirectGenerators fn Nothing DirectGeneratorSuggestModeMissing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
src/Database/V1/Bloodhound/Types/Internal.hsdeleted−57
@@ -1,57 +0,0 @@
1−{-# LANGUAGE DeriveDataTypeable #-}
2−{-# LANGUAGE DeriveGeneric #-}
3−{-# LANGUAGE FlexibleInstances #-}
4−{-# LANGUAGE GeneralizedNewtypeDeriving #-}
5−
6−-------------------------------------------------------------------------------
7−-- |
8−-- Module : Database.Bloodhound.Types.Internal
9−-- Copyright : (C) 2014 Chris Allen
10−-- License : BSD-style (see the file LICENSE)
11−-- Maintainer : Chris Allen <cma@bitemyapp.com>
12−-- Stability : provisional
13−-- Portability : DeriveGeneric, RecordWildCards
14−--
15−-- Internal data types for Bloodhound. These types may change without
16−-- notice so import at your own risk.
17−-------------------------------------------------------------------------------
18−module Database.V1.Bloodhound.Types.Internal
19− ( BHEnv(..)
20− , Server(..)
21− , MonadBH(..)
22− ) where
23−
24−
25−import Control.Applicative as A
26−import Control.Monad.Reader
27−import Data.Aeson
28−import Data.Text (Text)
29−import Data.Typeable (Typeable)
30−import GHC.Generics (Generic)
31−import Network.HTTP.Client
32−
33−{-| Common environment for Elasticsearch calls. Connections will be
34− pipelined according to the provided HTTP connection manager.
35−-}
36−data BHEnv = BHEnv { bhServer :: Server
37− , bhManager :: Manager
38− , bhRequestHook :: Request -> IO Request
39− -- ^ Low-level hook that is run before every request is sent. Used to implement custom authentication strategies. Defaults to 'return' with 'mkBHEnv'.
40− }
41−
42−instance (Functor m, Applicative m, MonadIO m) => MonadBH (ReaderT BHEnv m) where
43− getBHEnv = ask
44−
45−{-| 'Server' is used with the client functions to point at the ES instance
46−-}
47−newtype Server = Server Text deriving (Eq, Show, Generic, Typeable, FromJSON)
48−
49−{-| All API calls to Elasticsearch operate within
50− MonadBH
51− . The idea is that it can be easily embedded in your
52− own monad transformer stack. A default instance for a ReaderT and
53− alias 'BH' is provided for the simple case.
54−-}
55−class (Functor m, A.Applicative m, MonadIO m) => MonadBH m where
56− getBHEnv :: m BHEnv
57−