On Mon, Sep 19, 2011 at 3:50 AM, Charlie Hubbard
<[email protected]> wrote:
> Here was the prior API I was calling:
>
> Hits hits = getSearcher().search( query, filter, sort );
>
> The new API:
>
> TopDocs hits = getSearcher().search( query, filter, startDoc +
> length, sort );
>
> So the question is what new API can I use that allows me to extract all
> documents matching the query, sort, and filter in a efficient way?
How I do this:
// 1. Figure out how many results there will be.
class CountCollector extends Collector {
int count;
public void collect(int doc) {
count++;
}
// ... other empty methods ...
}
CountCollector collector = new CountCollector();
getSearcher().search(query, filter, collector);
int hitCount = collector.count;
// 2. Actually do the query.
hits = getSearcher().search(query, filter, hitCount, sort);
It is a bit unfortunate that there is no equivalent to TopDocs which
can grow dynamically, but this way is still going to be faster than
Hits was, for larger result sets.
TX
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]