From 5c7caa6f81ce073ef952b4d83a34eee2825ba515 Mon Sep 17 00:00:00 2001 From: Chris Allen Date: Sun, 15 Apr 2018 20:58:15 -0500 Subject: [PATCH] Index flushing, echo silence --- Makefile | 2 +- src/Database/V5/Bloodhound/Client.hs | 9 ++++++++- tests/V5/Test/Indices.hs | 7 +++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 37c8840..d6b4d7e 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ mod-build: stack build --ghc-options '+RTS -A128M -RTS' echo-warn: - echo "Make certain you have an elasticsearch instance on localhost:9200 !" + @echo "Make certain you have an elasticsearch instance on localhost:9200 !" 7.8-build: STACK_YAML="stack-7.8.yaml" stack build diff --git a/src/Database/V5/Bloodhound/Client.hs b/src/Database/V5/Bloodhound/Client.hs index 5488f5c..3a1994e 100644 --- a/src/Database/V5/Bloodhound/Client.hs +++ b/src/Database/V5/Bloodhound/Client.hs @@ -26,6 +26,7 @@ module Database.V5.Bloodhound.Client -- ** Indices , createIndex , createIndexWith + , flushIndex , deleteIndex , updateIndexSettings , getIndexSettings @@ -534,7 +535,13 @@ createIndexWith updates shards (IndexName indexName) = ) ] --- | 'deleteIndex' will delete an index given a 'Server', and an 'IndexName'. +-- | 'flushIndex' will flush an index given a 'Server' and an 'IndexName'. +flushIndex :: MonadBH m => IndexName -> m Reply +flushIndex (IndexName indexName) = do + path <- joinPath [indexName, "_flush"] + post path Nothing + +-- | 'deleteIndex' will delete an index given a 'Server' and an 'IndexName'. -- -- >>> _ <- runBH' $ createIndex defaultIndexSettings (IndexName "didimakeanindex") -- >>> response <- runBH' $ deleteIndex (IndexName "didimakeanindex") diff --git a/tests/V5/Test/Indices.hs b/tests/V5/Test/Indices.hs index 676e013..615056f 100644 --- a/tests/V5/Test/Indices.hs +++ b/tests/V5/Test/Indices.hs @@ -164,3 +164,10 @@ spec = do _ <- createExampleIndex resp <- forceMergeIndex (IndexList (testIndex :| [])) defaultForceMergeIndexSettings liftIO $ validateStatus resp 200 + + + describe "Index flushing" $ do + it "returns a successful response upon flushing" $ withTestEnv $ do + _ <- createExampleIndex + resp <- flushIndex testIndex + liftIO $ validateStatus resp 200