@@ -77,12 +77,12 @@ import Database.Bloodhound.Types
77-- >>> import Database.Bloodhound
77-- >>> import Database.Bloodhound
78-- >>> import Test.DocTest.Prop (assert)
78-- >>> import Test.DocTest.Prop (assert)
79-- >>> let testServer = (Server "http://localhost:9200")
79-- >>> let testServer = (Server "http://localhost:9200")
80−-- >>> let runBH = withBH defaultManagerSettings testServer
80+-- >>> let runBH' = withBH defaultManagerSettings testServer
81-- >>> let testIndex = IndexName "twitter"
81-- >>> let testIndex = IndexName "twitter"
82-- >>> let testMapping = MappingName "tweet"
82-- >>> let testMapping = MappingName "tweet"
83-- >>> let defaultIndexSettings = IndexSettings (ShardCount 3) (ReplicaCount 2)
83-- >>> let defaultIndexSettings = IndexSettings (ShardCount 3) (ReplicaCount 2)
84-- >>> data TweetMapping = TweetMapping deriving (Eq, Show)
84-- >>> data TweetMapping = TweetMapping deriving (Eq, Show)
85−-- >>> _ <- runBH $ deleteIndex testIndex >> deleteMapping testIndex testMapping
85+-- >>> _ <- runBH' $ deleteIndex testIndex >> deleteMapping testIndex testMapping
86-- >>> import GHC.Generics
86-- >>> import GHC.Generics
87-- >>> import Data.Time.Calendar (Day (..))
87-- >>> import Data.Time.Calendar (Day (..))
88-- >>> import Data.Time.Clock (UTCTime (..), secondsToDiffTime)
88-- >>> import Data.Time.Clock (UTCTime (..), secondsToDiffTime)
@@ -192,7 +192,7 @@ post = dispatch NHTM.methodPost
193-- | 'getStatus' fetches the 'Status' of a 'Server'
193-- | 'getStatus' fetches the 'Status' of a 'Server'
195−-- >>> serverStatus <- runBH getStatus
195+-- >>> serverStatus <- runBH' getStatus
196-- >>> fmap status (serverStatus)
196-- >>> fmap status (serverStatus)
197-- Just 200
197-- Just 200
198getStatus :: MonadBH m => m (Maybe Status)
198getStatus :: MonadBH m => m (Maybe Status)
@@ -205,10 +205,10 @@ getStatus = do
206-- | 'createIndex' will create an index given a 'Server', 'IndexSettings', and an 'IndexName'.
206-- | 'createIndex' will create an index given a 'Server', 'IndexSettings', and an 'IndexName'.
208−-- >>> response <- runBH $ createIndex defaultIndexSettings (IndexName "didimakeanindex")
208+-- >>> response <- runBH' $ createIndex defaultIndexSettings (IndexName "didimakeanindex")
209-- >>> respIsTwoHunna response
209-- >>> respIsTwoHunna response
211−-- >>> runBH $ indexExists (IndexName "didimakeanindex")
211+-- >>> runBH' $ indexExists (IndexName "didimakeanindex")
213createIndex :: MonadBH m => IndexSettings -> IndexName -> m Reply
213createIndex :: MonadBH m => IndexSettings -> IndexName -> m Reply
214createIndex indexSettings (IndexName indexName) =
214createIndex indexSettings (IndexName indexName) =
@@ -218,11 +218,11 @@ createIndex indexSettings (IndexName indexName) =
219-- | 'deleteIndex' will delete an index given a 'Server', and an 'IndexName'.
219-- | 'deleteIndex' will delete an index given a 'Server', and an 'IndexName'.
221−-- >>> _ <- runBH $ createIndex defaultIndexSettings (IndexName "didimakeanindex")
221+-- >>> _ <- runBH' $ createIndex defaultIndexSettings (IndexName "didimakeanindex")
222−-- >>> response <- runBH $ deleteIndex (IndexName "didimakeanindex")
222+-- >>> response <- runBH' $ deleteIndex (IndexName "didimakeanindex")
223-- >>> respIsTwoHunna response
223-- >>> respIsTwoHunna response
225−-- >>> runBH $ indexExists testIndex
225+-- >>> runBH' $ indexExists testIndex
227deleteIndex :: MonadBH m => IndexName -> m Reply
227deleteIndex :: MonadBH m => IndexName -> m Reply
228deleteIndex (IndexName indexName) =
228deleteIndex (IndexName indexName) =
@@ -242,7 +242,7 @@ existentialQuery url = do
242-- | 'indexExists' enables you to check if an index exists. Returns 'Bool'
242-- | 'indexExists' enables you to check if an index exists. Returns 'Bool'
245−-- >>> exists <- runBH $ indexExists testIndex
245+-- >>> exists <- runBH' $ indexExists testIndex
246indexExists :: MonadBH m => IndexName -> m Bool
246indexExists :: MonadBH m => IndexName -> m Bool
247indexExists (IndexName indexName) = do
247indexExists (IndexName indexName) = do
248 (_, exists) <- existentialQuery =<< joinPath [indexName]
248 (_, exists) <- existentialQuery =<< joinPath [indexName]
@@ -251,8 +251,8 @@ indexExists (IndexName indexName) = do
251-- | 'refreshIndex' will force a refresh on an index. You must
251-- | 'refreshIndex' will force a refresh on an index. You must
252-- do this if you want to read what you wrote.
252-- do this if you want to read what you wrote.
254−-- >>> _ <- runBH $ createIndex defaultIndexSettings testIndex
254+-- >>> _ <- runBH' $ createIndex defaultIndexSettings testIndex
255−-- >>> _ <- runBH $ refreshIndex testIndex
255+-- >>> _ <- runBH' $ refreshIndex testIndex
256refreshIndex :: MonadBH m => IndexName -> m Reply
256refreshIndex :: MonadBH m => IndexName -> m Reply
257refreshIndex (IndexName indexName) =
257refreshIndex (IndexName indexName) =
258 bindM2 post url (return Nothing)
258 bindM2 post url (return Nothing)
@@ -272,22 +272,22 @@ openOrCloseIndexes oci (IndexName indexName) =
272-- | 'openIndex' opens an index given a 'Server' and an 'IndexName'. Explained in further detail at
272-- | 'openIndex' opens an index given a 'Server' and an 'IndexName'. Explained in further detail at
273-- <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-open-close.html>
273-- <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-open-close.html>
275−-- >>> reply <- runBH $ openIndex testIndex
275+-- >>> reply <- runBH' $ openIndex testIndex
276openIndex :: MonadBH m => IndexName -> m Reply
276openIndex :: MonadBH m => IndexName -> m Reply
277openIndex = openOrCloseIndexes OpenIndex
277openIndex = openOrCloseIndexes OpenIndex
279-- | 'closeIndex' closes an index given a 'Server' and an 'IndexName'. Explained in further detail at
279-- | 'closeIndex' closes an index given a 'Server' and an 'IndexName'. Explained in further detail at
280-- <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-open-close.html>
280-- <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-open-close.html>
282−-- >>> reply <- runBH $ closeIndex testIndex
282+-- >>> reply <- runBH' $ closeIndex testIndex
283closeIndex :: MonadBH m => IndexName -> m Reply
283closeIndex :: MonadBH m => IndexName -> m Reply
284closeIndex = openOrCloseIndexes CloseIndex
284closeIndex = openOrCloseIndexes CloseIndex
286-- | 'putMapping' is an HTTP PUT and has upsert semantics. Mappings are schemas
286-- | 'putMapping' is an HTTP PUT and has upsert semantics. Mappings are schemas
287-- for documents in indexes.
287-- for documents in indexes.
289−-- >>> _ <- runBH $ createIndex defaultIndexSettings testIndex
289+-- >>> _ <- runBH' $ createIndex defaultIndexSettings testIndex
290−-- >>> resp <- runBH $ putMapping testIndex testMapping TweetMapping
290+-- >>> resp <- runBH' $ putMapping testIndex testMapping TweetMapping
291-- >>> print resp
291-- >>> print resp
292-- Response {responseStatus = Status {statusCode = 200, statusMessage = "OK"}, responseVersion = HTTP/1.1, responseHeaders = [("Content-Type","application/json; charset=UTF-8"),("Content-Length","21")], responseBody = "{\"acknowledged\":true}", responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}
292-- Response {responseStatus = Status {statusCode = 200, statusMessage = "OK"}, responseVersion = HTTP/1.1, responseHeaders = [("Content-Type","application/json; charset=UTF-8"),("Content-Length","21")], responseBody = "{\"acknowledged\":true}", responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}
293putMapping :: (MonadBH m, ToJSON a) => IndexName
293putMapping :: (MonadBH m, ToJSON a) => IndexName
@@ -300,9 +300,9 @@ putMapping (IndexName indexName) (MappingName mappingName) mapping =
300-- | 'deleteMapping' is an HTTP DELETE and deletes a mapping for a given index.
300-- | 'deleteMapping' is an HTTP DELETE and deletes a mapping for a given index.
301-- Mappings are schemas for documents in indexes.
301-- Mappings are schemas for documents in indexes.
303−-- >>> _ <- runBH $ createIndex defaultIndexSettings testIndex
303+-- >>> _ <- runBH' $ createIndex defaultIndexSettings testIndex
304−-- >>> _ <- runBH $ putMapping testIndex testMapping TweetMapping
304+-- >>> _ <- runBH' $ putMapping testIndex testMapping TweetMapping
305−-- >>> resp <- runBH $ deleteMapping testIndex testMapping
305+-- >>> resp <- runBH' $ deleteMapping testIndex testMapping
306-- >>> print resp
306-- >>> print resp
307-- Response {responseStatus = Status {statusCode = 200, statusMessage = "OK"}, responseVersion = HTTP/1.1, responseHeaders = [("Content-Type","application/json; charset=UTF-8"),("Content-Length","21")], responseBody = "{\"acknowledged\":true}", responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}
307-- Response {responseStatus = Status {statusCode = 200, statusMessage = "OK"}, responseVersion = HTTP/1.1, responseHeaders = [("Content-Type","application/json; charset=UTF-8"),("Content-Length","21")], responseBody = "{\"acknowledged\":true}", responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}
308deleteMapping :: MonadBH m => IndexName -> MappingName -> m Reply
308deleteMapping :: MonadBH m => IndexName -> MappingName -> m Reply
@@ -315,7 +315,7 @@ deleteMapping (IndexName indexName)
315-- convert into a JSON 'Value'. The 'DocId' will function as the
315-- convert into a JSON 'Value'. The 'DocId' will function as the
316-- primary key for the document.
316-- primary key for the document.
318−-- >>> resp <- runBH $ indexDocument testIndex testMapping exampleTweet (DocId "1")
318+-- >>> resp <- runBH' $ indexDocument testIndex testMapping exampleTweet (DocId "1")
319-- >>> print resp
319-- >>> print resp
320-- Response {responseStatus = Status {statusCode = 201, statusMessage = "Created"}, responseVersion = HTTP/1.1, responseHeaders = [("Content-Type","application/json; charset=UTF-8"),("Content-Length","74")], responseBody = "{\"_index\":\"twitter\",\"_type\":\"tweet\",\"_id\":\"1\",\"_version\":1,\"created\":true}", responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}
320-- Response {responseStatus = Status {statusCode = 201, statusMessage = "Created"}, responseVersion = HTTP/1.1, responseHeaders = [("Content-Type","application/json; charset=UTF-8"),("Content-Length","74")], responseBody = "{\"_index\":\"twitter\",\"_type\":\"tweet\",\"_id\":\"1\",\"_version\":1,\"created\":true}", responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}
321indexDocument :: (ToJSON doc, MonadBH m) => IndexName -> MappingName
321indexDocument :: (ToJSON doc, MonadBH m) => IndexName -> MappingName
@@ -328,7 +328,7 @@ indexDocument (IndexName indexName)
329-- | 'deleteDocument' is the primary way to delete a single document.
329-- | 'deleteDocument' is the primary way to delete a single document.
331−-- >>> _ <- runBH $ deleteDocument testIndex testMapping (DocId "1")
331+-- >>> _ <- runBH' $ deleteDocument testIndex testMapping (DocId "1")
332deleteDocument :: MonadBH m => IndexName -> MappingName
332deleteDocument :: MonadBH m => IndexName -> MappingName
333 -> DocId -> m Reply
333 -> DocId -> m Reply
334deleteDocument (IndexName indexName)
334deleteDocument (IndexName indexName)
@@ -343,8 +343,8 @@ deleteDocument (IndexName indexName)
343-- server to be performed. I changed from [BulkOperation] to a Vector due to memory overhead.
343-- server to be performed. I changed from [BulkOperation] to a Vector due to memory overhead.
345-- >>> let stream = V.fromList [BulkIndex testIndex testMapping (DocId "2") (toJSON (BulkTest "blah"))]
345-- >>> let stream = V.fromList [BulkIndex testIndex testMapping (DocId "2") (toJSON (BulkTest "blah"))]
346−-- >>> _ <- runBH $ bulk stream
346+-- >>> _ <- runBH' $ bulk stream
347−-- >>> _ <- runBH $ refreshIndex testIndex
347+-- >>> _ <- runBH' $ refreshIndex testIndex
348bulk :: MonadBH m => V.Vector BulkOperation -> m Reply
348bulk :: MonadBH m => V.Vector BulkOperation -> m Reply
349bulk bulkOps = bindM2 post url (return body)
349bulk bulkOps = bindM2 post url (return body)
350 where url = joinPath ["_bulk"]
350 where url = joinPath ["_bulk"]
@@ -408,7 +408,7 @@ encodeBulkOperation (BulkUpdate (IndexName indexName)
408-- Elasticsearch using a 'Server', 'IndexName', 'MappingName', and a 'DocId'.
408-- Elasticsearch using a 'Server', 'IndexName', 'MappingName', and a 'DocId'.
409-- The 'DocId' is the primary key for your Elasticsearch document.
409-- The 'DocId' is the primary key for your Elasticsearch document.
411−-- >>> yourDoc <- runBH $ getDocument testIndex testMapping (DocId "1")
411+-- >>> yourDoc <- runBH' $ getDocument testIndex testMapping (DocId "1")
412getDocument :: MonadBH m => IndexName -> MappingName
412getDocument :: MonadBH m => IndexName -> MappingName
413 -> DocId -> m Reply
413 -> DocId -> m Reply
414getDocument (IndexName indexName)
414getDocument (IndexName indexName)
@@ -418,7 +418,7 @@ getDocument (IndexName indexName)
418-- | 'documentExists' enables you to check if a document exists. Returns 'Bool'
418-- | 'documentExists' enables you to check if a document exists. Returns 'Bool'
421−-- >>> exists <- runBH $ documentExists testIndex testMapping (DocId "1")
421+-- >>> exists <- runBH' $ documentExists testIndex testMapping (DocId "1")
422documentExists :: MonadBH m => IndexName -> MappingName
422documentExists :: MonadBH m => IndexName -> MappingName
423 -> DocId -> m Bool
423 -> DocId -> m Bool
424documentExists (IndexName indexName)
424documentExists (IndexName indexName)
@@ -435,7 +435,7 @@ dispatchSearch url search = post url (Just (encode search))
436-- >>> let query = TermQuery (Term "user" "bitemyapp") Nothing
436-- >>> let query = TermQuery (Term "user" "bitemyapp") Nothing
437-- >>> let search = mkSearch (Just query) Nothing
437-- >>> let search = mkSearch (Just query) Nothing
438−-- >>> reply <- runBH $ searchAll search
438+-- >>> reply <- runBH' $ searchAll search
439searchAll :: MonadBH m => Search -> m Reply
439searchAll :: MonadBH m => Search -> m Reply
440searchAll = bindM2 dispatchSearch url . return
440searchAll = bindM2 dispatchSearch url . return
441 where url = joinPath ["_search"]
441 where url = joinPath ["_search"]
@@ -445,7 +445,7 @@ searchAll = bindM2 dispatchSearch url . return
446-- >>> let query = TermQuery (Term "user" "bitemyapp") Nothing
446-- >>> let query = TermQuery (Term "user" "bitemyapp") Nothing
447-- >>> let search = mkSearch (Just query) Nothing
447-- >>> let search = mkSearch (Just query) Nothing
448−-- >>> reply <- runBH $ searchByIndex testIndex search
448+-- >>> reply <- runBH' $ searchByIndex testIndex search
449searchByIndex :: MonadBH m => IndexName -> Search -> m Reply
449searchByIndex :: MonadBH m => IndexName -> Search -> m Reply
450searchByIndex (IndexName indexName) = bindM2 dispatchSearch url . return
450searchByIndex (IndexName indexName) = bindM2 dispatchSearch url . return
451 where url = joinPath [indexName, "_search"]
451 where url = joinPath [indexName, "_search"]
@@ -455,7 +455,7 @@ searchByIndex (IndexName indexName) = bindM2 dispatchSearch url . return
456-- >>> let query = TermQuery (Term "user" "bitemyapp") Nothing
456-- >>> let query = TermQuery (Term "user" "bitemyapp") Nothing
457-- >>> let search = mkSearch (Just query) Nothing
457-- >>> let search = mkSearch (Just query) Nothing
458−-- >>> reply <- runBH $ searchByType testIndex testMapping search
458+-- >>> reply <- runBH' $ searchByType testIndex testMapping search
459searchByType :: MonadBH m => IndexName -> MappingName -> Search
459searchByType :: MonadBH m => IndexName -> MappingName -> Search
460 -> m Reply
460 -> m Reply
461searchByType (IndexName indexName)
461searchByType (IndexName indexName)