Interface SearchScroll<H>
- Type Parameters:
H
- The type of hits.
- All Superinterfaces:
AutoCloseable
- All Known Subinterfaces:
ElasticsearchSearchScroll<H>
,ExtendedSearchScroll<H,
,R> LuceneSearchScroll<H>
This is different from classic pagination, where a loop executes the same query multiple times with an incrementing offset.
Classic pagination will execute the query against a different snapshot of the index for each call to fetch(...)
,
potentially leading to some hits appearing in two subsequent pages if the index was modified between two executions.
Scrolls do not suffer from this limitation and guarantee that each hit is returned only once.
As the scroll maintains a reference to internal resources that ultimately must be freed,
the client must call close()
when it no longer needs the scroll.
Additionally, some implementations have an internal timeout beyond which the scroll will automatically close
and will no longer be usable.
-
Method Details
-
close
void close()- Specified by:
close
in interfaceAutoCloseable
-
next
SearchScrollResult<H> next()Returns the next chunk, with at mostchunkSize
hits.May return a result with less than
chunkSize
elements if only that many hits are left.- Returns:
- The next
SearchScrollResult
. - See Also:
-