@@ -607,9 +607,19 @@ protected <A extends InternalAggregation, C extends Aggregator> A searchAndReduc
607
607
IndexSearcher searcher ,
608
608
Query query ,
609
609
AggregationBuilder builder ,
610
+ boolean shardFanOut ,
610
611
MappedFieldType ... fieldTypes
611
612
) throws IOException {
612
- return searchAndReduce (createIndexSettings (), searcher , query , builder , DEFAULT_MAX_BUCKETS , fieldTypes );
613
+ return searchAndReduce (createIndexSettings (), searcher , query , builder , DEFAULT_MAX_BUCKETS , shardFanOut , fieldTypes );
614
+ }
615
+
616
+ protected <A extends InternalAggregation , C extends Aggregator > A searchAndReduce (
617
+ IndexSearcher searcher ,
618
+ Query query ,
619
+ AggregationBuilder builder ,
620
+ MappedFieldType ... fieldTypes
621
+ ) throws IOException {
622
+ return searchAndReduce (createIndexSettings (), searcher , query , builder , DEFAULT_MAX_BUCKETS , randomBoolean (), fieldTypes );
613
623
}
614
624
615
625
protected <A extends InternalAggregation , C extends Aggregator > A searchAndReduce (
@@ -619,7 +629,7 @@ protected <A extends InternalAggregation, C extends Aggregator> A searchAndReduc
619
629
AggregationBuilder builder ,
620
630
MappedFieldType ... fieldTypes
621
631
) throws IOException {
622
- return searchAndReduce (indexSettings , searcher , query , builder , DEFAULT_MAX_BUCKETS , fieldTypes );
632
+ return searchAndReduce (indexSettings , searcher , query , builder , DEFAULT_MAX_BUCKETS , randomBoolean (), fieldTypes );
623
633
}
624
634
625
635
protected <A extends InternalAggregation , C extends Aggregator > A searchAndReduce (
@@ -629,7 +639,7 @@ protected <A extends InternalAggregation, C extends Aggregator> A searchAndReduc
629
639
int maxBucket ,
630
640
MappedFieldType ... fieldTypes
631
641
) throws IOException {
632
- return searchAndReduce (createIndexSettings (), searcher , query , builder , maxBucket , fieldTypes );
642
+ return searchAndReduce (createIndexSettings (), searcher , query , builder , maxBucket , randomBoolean (), fieldTypes );
633
643
}
634
644
635
645
protected <A extends InternalAggregation , C extends Aggregator > A searchAndReduce (
@@ -638,9 +648,10 @@ protected <A extends InternalAggregation, C extends Aggregator> A searchAndReduc
638
648
Query query ,
639
649
AggregationBuilder builder ,
640
650
int maxBucket ,
651
+ boolean shardFanOut ,
641
652
MappedFieldType ... fieldTypes
642
653
) throws IOException {
643
- return searchAndReduce (indexSettings , searcher , query , builder , maxBucket , false , fieldTypes );
654
+ return searchAndReduce (indexSettings , searcher , query , builder , maxBucket , false , shardFanOut , fieldTypes );
644
655
}
645
656
646
657
/**
@@ -658,6 +669,7 @@ protected <A extends InternalAggregation, C extends Aggregator> A searchAndReduc
658
669
AggregationBuilder builder ,
659
670
int maxBucket ,
660
671
boolean hasNested ,
672
+ boolean shardFanOut ,
661
673
MappedFieldType ... fieldTypes
662
674
) throws IOException {
663
675
final IndexReaderContext ctx = searcher .getTopReaderContext ();
@@ -673,7 +685,7 @@ protected <A extends InternalAggregation, C extends Aggregator> A searchAndReduc
673
685
);
674
686
C root = createAggregator (query , builder , searcher , bucketConsumer , fieldTypes );
675
687
676
- if (randomBoolean () && searcher .getIndexReader ().leaves ().size () > 0 ) {
688
+ if (shardFanOut && searcher .getIndexReader ().leaves ().size () > 0 ) {
677
689
assertThat (ctx , instanceOf (CompositeReaderContext .class ));
678
690
final CompositeReaderContext compCTX = (CompositeReaderContext ) ctx ;
679
691
final int size = compCTX .leaves ().size ();
0 commit comments