@@ -263,16 +263,10 @@ public void search(Query query, Collector collector) throws IOException {
263263 // search(LeafReaderContextPartition[] partitions, Weight weight, Collector collector)
264264 query = collector .scoreMode ().needsScores () ? rewrite (query ) : rewrite (new ConstantScoreQuery (query ));
265265 Weight weight = createWeight (query , collector .scoreMode (), 1 );
266- List <LeafReaderContext > leaves = getLeafContexts ();
267- if (leaves != null && !leaves .isEmpty ()) {
268- search (
269- leaves .stream ().map (LeafReaderContextPartition ::createForEntireSegment ).toArray (LeafReaderContextPartition []::new ),
270- weight ,
271- collector
272- );
273- } else {
274- searchContext .bucketCollectorProcessor ().processPostCollection (collector );
275- }
266+ LeafReaderContextPartition [] partitions = (getLeafContexts () == null )
267+ ? new LeafReaderContextPartition [0 ]
268+ : getLeafContexts ().stream ().map (LeafReaderContextPartition ::createForEntireSegment ).toArray (LeafReaderContextPartition []::new );
269+ search (partitions , weight , collector );
276270 }
277271
278272 public void search (
@@ -311,7 +305,7 @@ protected void search(LeafReaderContextPartition[] partitions, Weight weight, Co
311305 searchLeaf (partition .ctx , partition .minDocId , partition .maxDocId , weight , collector );
312306 }
313307 }
314- // FIXME : Make this a responsibility for the callers rather than implicitly getting it done.
308+ // TODO : Make this a responsibility for the callers rather than implicitly getting it done here ?
315309 searchContext .bucketCollectorProcessor ().processPostCollection (collector );
316310 } catch (Throwable t ) {
317311 searchContext .indexShard ().getSearchOperationListener ().onFailedSliceExecution (searchContext );
0 commit comments