git.iko.soy/typeable/bloodhound
on master help sign in
add command for searching multiple indices
commitc86b5195cdb946e1e5618bfb58648aae54804d3e authorAndrew Martin <andrew.thaddeus@gmail.com> dateThu 8 Feb 2018, 16:18 (9 years ago) parent3be3d8f
1 file changed+10
src/Database/V5/Bloodhound/Client.hs+10
src/Database/V5/Bloodhound/Client.hs+10
@@ -54,6 +54,7 @@ module Database.V5.Bloodhound.Client
5454 -- ** Searching
5555 , searchAll
5656 , searchByIndex
57+ , searchByIndices
5758 , searchByType
5859 , scanSearch
5960 , getInitialScroll
@@ -972,6 +973,15 @@ searchByIndex :: MonadBH m => IndexName -> Search -> m Reply
972973searchByIndex (IndexName indexName) = bindM2 dispatchSearch url . return
973974 where url = joinPath [indexName, "_search"]
974975
976+-- | 'searchByIndices' is a variant of 'searchByIndex' that executes a
977+-- 'Search' over many indices. This is much faster than using
978+-- 'mapM' to 'searchByIndex' over a collection since it only
979+-- causes a single HTTP request to be emitted.
980+searchByIndices :: MonadBH m => NonEmpty IndexName -> Search -> m Reply
981+searchByIndices ixs = bindM2 dispatchSearch url . return
982+ where url = joinPath [renderedIxs, "_search"]
983+ renderedIxs = T.intercalate (T.singleton ',') (map (\(IndexName t) -> t) (toList ixs))
984+
975985-- | 'searchByType', given a 'Search', 'IndexName', and 'MappingName', will perform that
976986-- search against a specific mapping within an index on an Elasticsearch server.
977987--