@@ -583,14 +583,17 @@ listIndices :: (MonadThrow m, MonadBH m) => m [IndexName]
583583listIndices =
584584 parse . responseBody =<< get =<< url
585585 where
586− url = joinPath ["_cat/indices?v"]
587− -- parses the tabular format the indices api provides
588− parse body = case T.lines (T.decodeUtf8 (L.toStrict body)) of
589− (hdr:rows) -> let ks = T.words hdr
590− keyedRows = [ HM.fromList (zip ks (T.words row)) | row <- rows ]
591− names = catMaybes (HM.lookup "index" <$> keyedRows)
592− in return (IndexName <$> names)
593− [] -> throwM (EsProtocolException body)
586+ url = joinPath ["_cat/indices?format=json"]
587+ parse body = maybe (throwM (EsProtocolException body)) return $ do
588+ vals <- decode body
589+ forM vals $ \val -> do
590+ case val of
591+ Object obj -> do
592+ indexVal <- HM.lookup "index" obj
593+ case indexVal of
594+ String txt -> Just (IndexName txt)
595+ _ -> Nothing
596+ _ -> Nothing
594597
595598-- | 'updateIndexAliases' updates the server's index alias
596599-- table. Operations are atomic. Explained in further detail at