@Override protected void doSetNextReader(LeafReaderContext context) throws IOException { if (docs != null) { matchingDocs.add(new MatchingDocs(this.context, docs.getDocIdSet(), totalHits, scores)); } docs = createDocs(context.reader().maxDoc()); totalHits = 0; if (keepScores) { scores = new float[64]; // some initial size } this.context = context; }