Buggy code:
public class QueryElevationComponent extends SearchComponent implements SolrCoreAware { private static Logger log = LoggerFactory . getLogger ( QueryElevationComponent . class ) ; static final String FIELD_TYPE = "queryFieldType" ; static final String CONFIG_FILE = "config-file" ; static final String EXCLUDE = "exclude" ; public static final String BOOSTED = "BOOSTED" ; public static final String EXCLUDED = "EXCLUDED" ; private SolrParams initArgs = null ; private Analyzer analyzer = null ; private String idField = null ; private FieldType idSchemaFT ; boolean forceElevation = false ; final Map < IndexReader , Map < String , QueryElevationComponent . ElevationObj > > elevationCache = new WeakHashMap < IndexReader , Map < String , QueryElevationComponent . ElevationObj > > ( ) ; class ElevationObj { final String text ; final String analyzed ; final TermQuery [ ] exclude ; final BooleanQuery include ; final Map < BytesRef , Integer > priority ; final Set < String > ids ; final Set < String > excludeIds ; ElevationObj ( String qstr , List < String > elevate , List < String > exclude ) throws IOException { } } @ Override public void init ( NamedList args ) { } public void inform ( SolrCore core ) { } Map < String , QueryElevationComponent . ElevationObj > getElevationMap ( IndexReader reader , SolrCore core ) throws Exception { } private Map < String , QueryElevationComponent . ElevationObj > loadElevationMap ( Config cfg ) throws IOException { } void setTopQueryResults ( IndexReader reader , String query , String [ ] ids , String [ ] ex ) throws IOException { } String getAnalyzedQuery ( String query ) throws IOException { } @ Override public void prepare ( ResponseBuilder rb ) throws IOException { } @ Override public void process ( ResponseBuilder rb ) throws IOException { } @ Override public String getDescription ( ) { } @ Override public String getSource ( ) { } @ Override public URL [ ] getDocs ( ) { } class ElevationComparatorSource extends FieldComparatorSource { private QueryElevationComponent . ElevationObj elevations ; private SentinelIntSet ordSet ; private BytesRef [ ] termValues ; public ElevationComparatorSource ( final QueryElevationComponent . ElevationObj elevations ) { } @ Override public FieldComparator < Integer > newComparator ( String fieldname , final int numHits , int sortPos , boolean reversed ) throws IOException { return new FieldComparator < Integer > ( ) { private final int [ ] values = new int [ numHits ] ; private int bottomVal ; private TermsEnum termsEnum ; private DocsEnum docsEnum ; Set < String > seen = new HashSet < String > ( elevations . ids . size ( ) ) ; @ Override public int compare ( int slot1 , int slot2 ) { return ( values [ slot1 ] ) - ( values [ slot2 ] ) ; } @ Override public void setBottom ( int slot ) { bottomVal = values [ slot ] ; } private int docVal ( int doc ) { if ( ( ordSet . size ( ) ) > 0 ) { int slot = ordSet . find ( doc ) ; if ( slot >= 0 ) { BytesRef id = termValues [ slot ] ; Integer prio = elevations . priority . get ( id ) ; return prio == null ? 0 : prio . intValue ( ) ; } } return 0 ; } @ Override public int compareBottom ( int doc ) { return ( bottomVal ) - ( docVal ( doc ) ) ; } @ Override public void copy ( int slot , int doc ) { values [ slot ] = docVal ( doc ) ; } @ Override public FieldComparator setNextReader ( AtomicReaderContext context ) throws IOException { ordSet . clear ( ) ; Fields fields = context . reader ( ) . fields ( ) ; if ( fields == null ) return this ; Terms terms = fields . terms ( idField ) ; if ( terms == null ) return this ; termsEnum = terms . iterator ( termsEnum ) ; BytesRef term = new BytesRef ( ) ; Bits liveDocs = context . reader ( ) . getLiveDocs ( ) ; for ( String id : elevations . ids ) { term . copyChars ( id ) ; if ( ( ( seen . contains ( id ) ) == false ) && ( termsEnum . seekExact ( term , false ) ) ) { <START_BUG> docsEnum = termsEnum . docs ( liveDocs , docsEnum , false ) ; <END_BUG> if ( ( docsEnum ) != null ) { int docId = docsEnum . nextDoc ( ) ; if ( docId == ( DocIdSetIterator . NO_MORE_DOCS ) ) continue ; termValues [ ordSet . put ( docId ) ] = BytesRef . deepCopyOf ( term ) ; seen . add ( id ) ; assert ( docsEnum . nextDoc ( ) ) == ( DocIdSetIterator . NO_MORE_DOCS ) ; } } } return this ; } @ Override public Integer value ( int slot ) { return values [ slot ] ; } @ Override public int compareDocToValue ( int doc , Integer valueObj ) { final int value = valueObj . intValue ( ) ; final int docValue = docVal ( doc ) ; return docValue - value ; } } ; } } }

Fix:
docsEnum = termsEnum . docs ( liveDocs , docsEnum , 0 ) ;