@@ -532,10 +532,6 @@ createIndexWith updates shards (IndexName indexName) =
532532 )
533533 ]
534534
535−oPath :: ToJSON a => NonEmpty Text -> a -> Value
536−oPath (k :| []) v = object [k .= v]
537−oPath (k:| (h:t)) v = object [k .= oPath (h :| t) v]
538−
539535-- | 'deleteIndex' will delete an index given a 'Server', and an 'IndexName'.
540536--
541537-- >>> _ <- runBH' $ createIndex defaultIndexSettings (IndexName "didimakeanindex")
@@ -703,14 +699,17 @@ listIndices :: (MonadThrow m, MonadBH m) => m [IndexName]
703699listIndices =
704700 parse . responseBody =<< get =<< url
705701 where
706− url = joinPath ["_cat/indices?v"]
707− -- parses the tabular format the indices api provides
708− parse body = case T.lines (T.decodeUtf8 (L.toStrict body)) of
709− (hdr:rows) -> let ks = T.words hdr
710− keyedRows = [ HM.fromList (zip ks (T.words row)) | row <- rows ]
711− names = catMaybes (HM.lookup "index" <$> keyedRows)
712− in return (IndexName <$> names)
713− [] -> throwM (EsProtocolException body)
702+ url = joinPath ["_cat/indices?format=json"]
703+ parse body = maybe (throwM (EsProtocolException body)) return $ do
704+ vals <- decode body
705+ forM vals $ \val -> do
706+ case val of
707+ Object obj -> do
708+ indexVal <- HM.lookup "index" obj
709+ case indexVal of
710+ String txt -> Just (IndexName txt)
711+ _ -> Nothing
712+ _ -> Nothing
714713
715714-- | 'updateIndexAliases' updates the server's index alias
716715-- table. Operations are atomic. Explained in further detail at