git.iko.soy/typeable/bloodhound
on master help sign in
tests pass, sanity restored
commit0523803114c50e8dd1133eced085f691c607ae1d authorChris Allen <cma@bitemyapp.com> dateThu 10 Apr 2014, 01:41 (13 years ago) parent3908ca6
2 files changed+22−13
Database/Bloodhound/Client.hs+12−5 tests/tests.hs+10−8
Database/Bloodhound/Client.hs+12−5
@@ -3,20 +3,21 @@
33module Database.Bloodhound.Client
44 ( createIndex
55 , deleteIndex
6− , IndexSettings(..)
7− , Server(..)
86 , defaultIndexSettings
97 , indexDocument
108 , getDocument
119 , documentExists
1210 , deleteDocument
11+ , searchAll
12+ , searchByIndex
13+ , searchByType
14+ , refreshIndex
15+ , IndexSettings(..)
16+ , Server(..)
1317 , Reply(..)
1418 , EsResult(..)
1519 , Query(..)
1620 , Search(..)
17− , searchAll
18− , searchByIndex
19− , searchByType
2021 , SearchResult(..)
2122 , SearchHits(..)
2223 , ShardResult(..)
@@ -260,6 +261,12 @@ searchByType :: Server -> IndexName -> MappingName -> Search -> IO Reply
260261searchByType (Server server) indexName mappingName search = dispatchSearch url search where
261262 url = joinPath [server, indexName, mappingName, "_search"]
262263
264+refreshIndex :: Server -> IndexName -> IO Reply
265+refreshIndex (Server server) indexName = dispatch url method body where
266+ url = joinPath [server, indexName, "_refresh"]
267+ method = NHTM.methodPost
268+ body = Nothing
269+
263270data Search = Search { queryBody :: Maybe Query
264271 , filterBody :: Maybe Filter } deriving (Show)
265272
tests/tests.hs+10−8
@@ -42,6 +42,7 @@ insertData = do
4242 _ <- deleteExampleIndex
4343 created <- createExampleIndex
4444 docCreated <- indexDocument (Server "http://localhost:9200") "twitter" "tweet" exampleTweet "1"
45+ _ <- refreshIndex testServer "twitter"
4546 return ()
4647
4748queryTweet :: IO (Either String Tweet)
@@ -56,17 +57,18 @@ queryTweet = do
5657
5758main :: IO ()
5859main = hspec $ do
59− -- describe "index create/delete API" $ do
60− -- it "creates and then deletes the requested index" $ do
61− -- -- priming state.
62− -- _ <- deleteExampleIndex
63− -- resp <- createExampleIndex
64− -- deleteResp <- deleteExampleIndex
65− -- validateStatus resp 200
66− -- validateStatus deleteResp 200
60+ describe "index create/delete API" $ do
61+ it "creates and then deletes the requested index" $ do
62+ -- priming state.
63+ _ <- deleteExampleIndex
64+ resp <- createExampleIndex
65+ deleteResp <- deleteExampleIndex
66+ validateStatus resp 200
67+ validateStatus deleteResp 200
6768
6869 describe "document API" $ do
6970 it "indexes, gets, and then deletes the generated document" $ do
71+ _ <- insertData
7072 docInserted <- getDocument (Server "http://localhost:9200") "twitter" "tweet" "1"
7173 let newTweet = eitherDecode (responseBody docInserted) :: Either String (EsResult Tweet)
7274 fmap _source newTweet `shouldBe` Right exampleTweet