sorted version of getInitialScroll for V5 client

This commit is contained in:
Matthew Wraith 2017-02-20 11:24:30 -06:00
parent 2f0676d73c
commit b7865504e4

View File

@ -55,6 +55,7 @@ module Database.V5.Bloodhound.Client
, searchByType
, scanSearch
, getInitialScroll
, getInitialSortedScroll
, advanceScroll
, refreshIndex
, mkSearch
@ -955,6 +956,21 @@ getInitialScroll (IndexName indexName) (MappingName mappingName) search' = do
resp' <- bindM2 dispatchSearch url (return search)
parseEsResponse resp'
-- | For a given scearch, request a scroll for efficient streaming of
-- search results. Combine this with 'advanceScroll' to efficiently
-- stream through the full result set. Note that this search respects
-- sorting and may be less efficient than 'getInitialScroll'.
getInitialSortedScroll ::
(FromJSON a, MonadThrow m, MonadBH m) => IndexName ->
MappingName ->
Search ->
m (Either EsError (SearchResult a))
getInitialSortedScroll (IndexName indexName) (MappingName mappingName) search = do
let url = addQuery params <$> joinPath [indexName, mappingName, "_search"]
params = [("scroll", Just "1m")]
resp' <- bindM2 dispatchSearch url (return search)
parseEsResponse resp'
scroll' :: (FromJSON a, MonadBH m, MonadThrow m) => Maybe ScrollId ->
m ([Hit a], Maybe ScrollId)
scroll' Nothing = return ([], Nothing)