git.iko.soy/typeable/bloodhound
on master help sign in
sorted version of getInitialScroll for V5 client
commitb7865504e46b90efe9e6e985fa2f8dea018d9843 authorMatthew Wraith <wraithm@gmail.com> dateMon 20 Feb 2017, 11:24 (10 years ago) parent2f0676d
1 file changed+16
src/Database/V5/Bloodhound/Client.hs+16
src/Database/V5/Bloodhound/Client.hs+16
@@ -55,6 +55,7 @@ module Database.V5.Bloodhound.Client
5555 , searchByType
5656 , scanSearch
5757 , getInitialScroll
58+ , getInitialSortedScroll
5859 , advanceScroll
5960 , refreshIndex
6061 , mkSearch
@@ -955,6 +956,21 @@ getInitialScroll (IndexName indexName) (MappingName mappingName) search' = do
955956 resp' <- bindM2 dispatchSearch url (return search)
956957 parseEsResponse resp'
957958
959+-- | For a given scearch, request a scroll for efficient streaming of
960+-- search results. Combine this with 'advanceScroll' to efficiently
961+-- stream through the full result set. Note that this search respects
962+-- sorting and may be less efficient than 'getInitialScroll'.
963+getInitialSortedScroll ::
964+ (FromJSON a, MonadThrow m, MonadBH m) => IndexName ->
965+ MappingName ->
966+ Search ->
967+ m (Either EsError (SearchResult a))
968+getInitialSortedScroll (IndexName indexName) (MappingName mappingName) search = do
969+ let url = addQuery params <$> joinPath [indexName, mappingName, "_search"]
970+ params = [("scroll", Just "1m")]
971+ resp' <- bindM2 dispatchSearch url (return search)
972+ parseEsResponse resp'
973+
958974scroll' :: (FromJSON a, MonadBH m, MonadThrow m) => Maybe ScrollId ->
959975 m ([Hit a], Maybe ScrollId)
960976scroll' Nothing = return ([], Nothing)