protected final void search(final Query query, final DocumentFrequencyWritable freqs, final String[] shards,
final HitsMapWritable result, final int max, Sort sort, long timeout) throws IOException {
timeout = getCollectorTiemout(timeout);
final Query rewrittenQuery = rewrite(query, shards);
final int numDocs = freqs.getNumDocsAsInteger();
final Weight weight = rewrittenQuery.weight(new CachedDfSource(freqs.getAll(), numDocs, new DefaultSimilarity()));
int totalHits = 0;
final int shardsCount = shards.length;
// Run the search in parallel on the shards with a thread pool.
CompletionService<SearchResult> csSearch = new ExecutorCompletionService<SearchResult>(_threadPool);