collect

abstract fun collect(doc: Int)

Called once for every document matching a query, with the unbased document number.

Note: The collection of the current segment can be terminated by throwing a [ ]. In this case, the last docs of the current [ ] will be skipped and IndexSearcher will swallow the exception and continue collection with the next leaf.

Note: This is called in an inner search loop. For good search performance, implementations of this method should not call StoredFields.document on every hit. Doing so can slow searches by an order of magnitude or more.


open fun collect(stream: DocIdStream)

Bulk-collect doc IDs.

Note: The provided DocIdStream may be reused across calls and should be consumed immediately.

Note: The provided DocIdStream typically only holds a small subset of query matches. This method may be called multiple times per segment.

Like .collect, it is guaranteed that doc IDs get collected in order, ie. doc IDs are collected in order within a DocIdStream, and if called twice, all doc IDs from the second DocIdStream will be greater than all doc IDs from the first [ ].

It is legal for callers to mix calls to .collect and .collect.

The default implementation calls stream.forEach(this::collect).