Class CachingCollector

Caches all docs, and optionally also scores, coming from
a search, and is then able to replay them to another
collector. You specify the max RAM this class may use.
Once the collection is done, call isCached(). If
this returns true, you can use replay(Collector)
against a new collector. If it returns false, this means
too much RAM was required and you must instead re-run the
original search.

NOTE: this class consumes 4 (or 8 bytes, if
scoring is cached) per collected document. If the result
set is large this can easily be a very substantial amount
of RAM!

acceptsDocsOutOfOrder

Return true if this collector does not
require the matching docIDs to be delivered in int sort
order (smallest to largest) to Collector.collect(int).

Most Lucene Query implementations will visit
matching docIDs in order. However, some queries
(currently limited to certain cases of BooleanQuery) can achieve faster searching if the
Collector allows them to deliver the
docIDs out of order.

Many collectors don't mind getting docIDs out of
order, so it's important to return true
here.