git.iko.soy/typeable/bloodhound
on master help sign in
Merge pull request #224 from andrewthad/search_indices
3cb5907Chris Allen
src/Database/V5/Bloodhound/Client.hs+10
@@ -54,6 +54,7 @@ module Database.V5.Bloodhound.Client
54 -- ** Searching
54 -- ** Searching
55 , searchAll
55 , searchAll
56 , searchByIndex
56 , searchByIndex
57+ , searchByIndices
57 , searchByType
58 , searchByType
58 , scanSearch
59 , scanSearch
59 , getInitialScroll
60 , getInitialScroll
@@ -972,6 +973,15 @@ searchByIndex :: MonadBH m => IndexName -> Search -> m Reply
972searchByIndex (IndexName indexName) = bindM2 dispatchSearch url . return
973searchByIndex (IndexName indexName) = bindM2 dispatchSearch url . return
973 where url = joinPath [indexName, "_search"]
974 where url = joinPath [indexName, "_search"]
974
975
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+
975-- | 'searchByType', given a 'Search', 'IndexName', and 'MappingName', will perform that
985-- | 'searchByType', given a 'Search', 'IndexName', and 'MappingName', will perform that
976-- search against a specific mapping within an index on an Elasticsearch server.
986-- search against a specific mapping within an index on an Elasticsearch server.
977--
987--