Buggy code:
if ( suggestions != null ) { List < Object > collationList = suggestions . getAll ( "collation" ) ; List < Object > collationRankList = suggestions . getAll ( "collationInternalRank" ) ; int i = 0 ; if ( collationList != null ) { for ( Object o : collationList ) { if ( o instanceof String ) { SpellCheckCollation coll = new SpellCheckCollation ( ) ; coll . setCollationQuery ( ( ( String ) ( o ) ) ) ; if ( ( collationRankList != null ) && ( ( collationRankList . size ( ) ) > 0 ) ) { coll . setInternalRank ( ( ( Integer ) ( collationRankList . get ( i ) ) ) ) ; i ++ ; } SpellCheckCollation priorColl = collations . get ( coll . getCollationQuery ( ) ) ; if ( priorColl != null ) { coll . setInternalRank ( Math . max ( coll . getInternalRank ( ) , priorColl . getInternalRank ( ) ) ) ; } collations . put ( coll . getCollationQuery ( ) , coll ) ; } else { NamedList expandedCollation = ( ( NamedList ) ( o ) ) ; SpellCheckCollation coll = new SpellCheckCollation ( ) ; coll . setCollationQuery ( ( ( String ) ( expandedCollation . get ( "collationQuery" ) ) ) ) ; coll . setHits ( ( ( Integer ) ( expandedCollation . get ( "hits" ) ) ) ) ; if ( maxCollationTries > 0 ) { coll . setInternalRank ( ( ( Integer ) ( expandedCollation . get ( "collationInternalRank" ) ) ) ) ; } coll . setMisspellingsAndCorrections ( ( ( NamedList ) ( expandedCollation . get ( "misspellingsAndCorrections" ) ) ) ) ; SpellCheckCollation priorColl = collations . get ( coll . getCollationQuery ( ) ) ; if ( priorColl != null ) { coll . setHits ( ( ( coll . getHits ( ) ) + ( priorColl . getHits ( ) ) ) ) ; coll . setInternalRank ( Math . max ( coll . getInternalRank ( ) , priorColl . getInternalRank ( ) ) ) ; } collations . put ( coll . getCollationQuery ( ) , coll ) ; } } } } } } } SpellingResult result = new SpellingResult ( tokens ) ; for ( Map . Entry < String , HashSet < String > > entry : origVsSuggested . entrySet ( ) ) { String original = entry . getKey ( ) ; Integer numShards = origVsShards . get ( original ) ; if ( numShards < totalNumberShardResponses ) { continue ; } HashSet < String > suggested = entry . getValue ( ) ; SuggestWordQueue sugQueue = new SuggestWordQueue ( numSug ) ; for ( String suggestion : suggested ) { SuggestWord sug = suggestedVsWord . get ( suggestion ) ; sug . score = sd . getDistance ( original , sug . string ) ; if ( ( sug . score ) < min ) continue ; sugQueue . insertWithOverflow ( sug ) ; if ( ( sugQueue . size ( ) ) == numSug ) { min = sugQueue . top ( ) . score ; } } SpellCheckResponse . Suggestion suggestion = origVsSuggestion . get ( original ) ; Token token = new Token ( original , suggestion . getStartOffset ( ) , suggestion . getEndOffset ( ) ) ; SuggestWord [ ] suggestions = new SuggestWord [ Math . min ( count , sugQueue . size ( ) ) ] ; for ( int k = 0 ; k < ( ( sugQueue . size ( ) ) - count ) ; k ++ ) sugQueue . pop ( ) ; for ( int k = ( Math . min ( count , sugQueue . size ( ) ) ) - 1 ; k >= 0 ; k -- ) { suggestions [ k ] = sugQueue . pop ( ) ; } if ( extendedResults ) { Integer o = origVsFreq . get ( original ) ; if ( o != null ) <START_BUG> result . add ( token , o ) ; <END_BUG> for ( SuggestWord word : suggestions ) result . add ( token , word . string , word . freq ) ; } else { List < String > words = new ArrayList < String > ( sugQueue . size ( ) ) ; for ( SuggestWord word : suggestions ) words . add ( word . string ) ; result . add ( token , words ) ; } } NamedList response = new SimpleOrderedMap ( ) ; NamedList suggestions = toNamedList ( false , result , origQuery , extendedResults , collate ) ; if ( collate ) { SpellCheckCollation [ ] sortedCollations = collations . values ( ) . toArray ( new SpellCheckCollation [ collations . size ( ) ] ) ; Arrays . sort ( sortedCollations ) ; int i = 0 ; while ( ( i < maxCollations ) && ( i < ( sortedCollations . length ) ) ) { SpellCheckCollation collation = sortedCollations [ i ] ; i ++ ; if ( collationExtendedResults ) { NamedList extendedResult = new NamedList ( ) ; extendedResult . add ( "collationQuery" , collation . getCollationQuery ( ) ) ; extendedResult . add ( "hits" , collation . getHits ( ) ) ; extendedResult . add ( "misspellingsAndCorrections" , collation . getMisspellingsAndCorrections ( ) ) ; suggestions . add ( "collation" , extendedResult ) ; } else { suggestions . add ( "collation" , collation . getCollationQuery ( ) ) ; } } } response . add ( "suggestions" , suggestions ) ; rb . rsp . add ( "spellcheck" , response ) ; } private Collection < Token > getTokens ( String q , Analyzer analyzer ) throws IOException { } protected SolrSpellChecker getSpellChecker ( SolrParams params ) { }

Fix:
result . addFrequency ( token , o ) ;