git.iko.soy/typeable/bloodhound
on master help sign in
Add example for updateIndexAliases

Can't run it locally right now. Doctests seems to get 2 different versions of http-types. Sweet.

commit5513b473bd7c71e9d864aa83a0e6619cb7003908 authorMichael Xavier <michael@michaelxavier.net> dateThu 29 Oct 2015, 22:16 (11 years ago) parent27e244e
1 file changed+12
src/Database/Bloodhound/Client.hs+12
src/Database/Bloodhound/Client.hs+12
@@ -344,6 +344,18 @@ openIndex = openOrCloseIndexes OpenIndex
344344closeIndex :: MonadBH m => IndexName -> m Reply
345345closeIndex = openOrCloseIndexes CloseIndex
346346
347+
348+-- | 'updateIndexAliases' updates the server's index alias
349+-- table. Operations are atomic. Explained in further detail at
350+-- <https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html>
351+--
352+-- >>> let aliasName = IndexName "twitter-alias"
353+-- >>> let iAlias = IndexAlias testIndex (IndexAliasName aliasName)
354+-- >>> let aliasCreate = IndexAliasCreate Nothing Nothing
355+-- >>> respIsTwoHunna <$> runBH' (updateIndexAliases (AddAlias iAlias aliasCreate :| []))
356+-- True
357+-- >> respIsTwoHunna <$> runBH' (indexExists aliasName)
358+-- True
347359updateIndexAliases :: MonadBH m => NE.NonEmpty IndexAliasAction -> m Reply
348360updateIndexAliases actions = bindM2 post url (return body)
349361 where url = joinPath ["_aliases"]