Buggy code:
public class SimpleFacets { protected DocSet docsOrig ; protected SolrParams params ; protected SolrParams required ; protected SolrIndexSearcher searcher ; protected SolrQueryRequest req ; protected ResponseBuilder rb ; protected SimpleOrderedMap < Object > facetResponse ; protected SolrParams localParams ; protected String facetValue ; protected DocSet docs ; protected String key ; protected int threads ; public SimpleFacets ( SolrQueryRequest req , DocSet docs , SolrParams params ) { } public SimpleFacets ( SolrQueryRequest req , DocSet docs , SolrParams params , ResponseBuilder rb ) { } protected void parseParams ( String type , String param ) throws IOException , SyntaxError { } public NamedList < Object > getFacetCounts ( ) { } public NamedList < Integer > getFacetQueryCounts ( ) throws IOException , SyntaxError { } public int getGroupedFacetQueryCount ( Query facetQuery ) throws IOException { GroupingSpecification groupingSpecification = rb . getGroupingSpec ( ) ; String groupField = ( groupingSpecification != null ) ? groupingSpecification . getFields ( ) [ 0 ] : null ; if ( groupField == null ) { throw new org . apache . solr . common . SolrException ( ErrorCode . BAD_REQUEST , "Specify<seq2seq4repair_space>the<seq2seq4repair_space>group.field<seq2seq4repair_space>as<seq2seq4repair_space>parameter<seq2seq4repair_space>or<seq2seq4repair_space>local<seq2seq4repair_space>parameter" ) ; } TermAllGroupsCollector collector = new TermAllGroupsCollector ( groupField ) ; <START_BUG> Filter mainQueryFilter = docsOrig . getTopFilter ( ) ; <END_BUG> searcher . search ( facetQuery , mainQueryFilter , collector ) ; return collector . getGroupCount ( ) ; } enum FacetMethod { ENUM , FC , FCS ; } public NamedList < Integer > getTermCounts ( String field ) throws IOException { } public NamedList < Integer > getGroupedCounts ( SolrIndexSearcher searcher , DocSet base , String field , boolean multiToken , int offset , int limit , int mincount , boolean missing , String sort , String prefix ) throws IOException { } static final Executor directExecutor = new Executor ( ) { @ Override public void execute ( Runnable r ) { } } ; static final Executor facetExecutor = new ThreadPoolExecutor ( 0 , Integer . MAX_VALUE , 10 , TimeUnit . SECONDS , new SynchronousQueue < Runnable > ( ) , new DefaultSolrThreadFactory ( "facetExecutor" ) ) ; public NamedList < Object > getFacetFieldCounts ( ) throws IOException , SyntaxError { } private NamedList < Integer > getListedTermCounts ( String field , String termList ) throws IOException { } public static int getFieldMissingCount ( SolrIndexSearcher searcher , DocSet docs , String fieldName ) throws IOException { } public static NamedList < Integer > getFieldCacheCounts ( SolrIndexSearcher searcher , DocSet docs , String fieldName , int offset , int limit , int mincount , boolean missing , String sort , String prefix ) throws IOException { } public NamedList < Integer > getFacetTermEnumCounts ( SolrIndexSearcher searcher , DocSet docs , String field , int offset , int limit , int mincount , boolean missing , String sort , String prefix ) throws IOException { } @ Deprecated public NamedList < Object > getFacetDateCounts ( ) throws IOException , SyntaxError { } @ Deprecated public void getFacetDateCounts ( String dateFacet , NamedList < Object > resOuter ) throws IOException , SyntaxError { } public NamedList < Object > getFacetRangeCounts ( ) throws IOException , SyntaxError { } void getFacetRangeCounts ( String facetRange , NamedList < Object > resOuter ) throws IOException , SyntaxError { } private < T extends Comparable < T > > NamedList getFacetRangeCounts ( final SchemaField sf , final SimpleFacets . RangeEndpointCalculator < T > calc ) throws IOException { } protected int rangeCount ( SchemaField sf , String low , String high , boolean iLow , boolean iHigh ) throws IOException { } @ Deprecated protected int rangeCount ( SchemaField sf , Date low , Date high , boolean iLow , boolean iHigh ) throws IOException { } public static class CountPair < K extends Comparable < ? super K > , V extends Comparable < ? super V > > implements Comparable < SimpleFacets . CountPair < K , V > > { public CountPair ( K k , V v ) { } public K key ; public V val ; @ Override public int hashCode ( ) { } @ Override public boolean equals ( Object o ) { } @ Override public int compareTo ( SimpleFacets . CountPair < K , V > o ) { } } private abstract static class RangeEndpointCalculator < T extends Comparable < T > > { protected final SchemaField field ; public RangeEndpointCalculator ( final SchemaField field ) { } public String formatValue ( final T val ) { } public final T getValue ( final String rawval ) { } protected abstract T parseVal ( final String rawval ) throws ParseException { } public final Object getGap ( final String gap ) { } protected Object parseGap ( final String rawval ) throws ParseException { } public final T addGap ( T value , String gap ) { } protected abstract T parseAndAddGap ( T value , String gap ) throws ParseException { } } private static class FloatRangeEndpointCalculator extends SimpleFacets . RangeEndpointCalculator < Float > { public FloatRangeEndpointCalculator ( final SchemaField f ) { } @ Override protected Float parseVal ( String rawval ) { } @ Override public Float parseAndAddGap ( Float value , String gap ) { } } private static class DoubleRangeEndpointCalculator extends SimpleFacets . RangeEndpointCalculator < Double > { public DoubleRangeEndpointCalculator ( final SchemaField f ) { } @ Override protected Double parseVal ( String rawval ) { } @ Override public Double parseAndAddGap ( Double value , String gap ) { } } private static class IntegerRangeEndpointCalculator extends SimpleFacets . RangeEndpointCalculator < Integer > { public IntegerRangeEndpointCalculator ( final SchemaField f ) { } @ Override protected Integer parseVal ( String rawval ) { } @ Override public Integer parseAndAddGap ( Integer value , String gap ) { } } private static class LongRangeEndpointCalculator extends SimpleFacets . RangeEndpointCalculator < Long > { public LongRangeEndpointCalculator ( final SchemaField f ) { }

Fix:
Filter mainQueryFilter = docs . getTopFilter ( ) ;