Use bulk iteration for index-sorted scroll ranges
Description
Later scroll pages can restrict collection to a contiguous document-ID range when the search sort matches the index sort. SearchAfterSortedDocQuery currently represents that range with MinDocQuery.MinDocIterator. This custom iterator inherits Lucene's scalar defaults for intoBitSet and docIDRunEnd, so dense filtered conjunctions cannot take advantage of the range's bulk operations.
Lucene's existing DocIdSetIterator.range(minDoc, maxDoc) represents the same bounds and overrides both operations. Delegating to it would also remove the duplicate iterator implementation from OpenSearch.
The affected code is in server/src/main/java/org/opensearch/lucene/queries/{MinDocQuery,SearchAfterSortedDocQuery}.java. This is present on main at 10a468295624e344e1e564d07ecf8667020024c5, with Lucene 10.5.1.
Expected behavior
Use Lucene's range iterator after checking for an empty range. Preserve matching documents, sort order, pagination, cacheability, and existing index compatibility.
Validation
Compare filtered and unfiltered later pages on the same index, including sparse/dense filters, small/large pages, descending sort, multiple segments, and deletions. Check complete results against ordinary IndexSearcher.searchAfter, and cover the production scroll path with a multi-shard integration test.
A query benchmark and an implementation are prepared. The benchmark measures query execution and sorted collection; it does not measure HTTP, distributed coordination, or stored-field fetch.
Source: opensearch-project/OpenSearch