git.iko.soy/typeable/bloodhound
on master help sign in
add function for checking index status
cb915c7Andrew Martin
src/Database/Bloodhound/Client.hs+9
@@ -33,6 +33,7 @@ module Database.Bloodhound.Client
33 , openIndex
33 , openIndex
34 , closeIndex
34 , closeIndex
35 , listIndices
35 , listIndices
36+ , waitForYellowIndex
36 -- *** Index Aliases
37 -- *** Index Aliases
37 , updateIndexAliases
38 , updateIndexAliases
38 , getIndexAliases
39 , getIndexAliases
@@ -633,6 +634,14 @@ refreshIndex (IndexName indexName) =
633 bindM2 post url (return Nothing)
634 bindM2 post url (return Nothing)
634 where url = joinPath [indexName, "_refresh"]
635 where url = joinPath [indexName, "_refresh"]
635
636
637+-- | Block until the index becomes available for indexing
638+-- documents. This is useful for integration tests in which
639+-- indices are rapidly created and deleted.
640+waitForYellowIndex :: MonadBH m => IndexName -> m Reply
641+waitForYellowIndex (IndexName indexName) = get =<< url
642+ where url = addQuery q <$> joinPath ["_cluster","health",indexName]
643+ q = [("wait_for_status",Just "yellow"),("timeout",Just "10s")]
644+
636stringifyOCIndex :: OpenCloseIndex -> Text
645stringifyOCIndex :: OpenCloseIndex -> Text
637stringifyOCIndex oci = case oci of
646stringifyOCIndex oci = case oci of
638 OpenIndex -> "_open"
647 OpenIndex -> "_open"