Buggy code:
public class MultiPhraseQuery extends Query { private String field ; private ArrayList < Term [ ] > termArrays = new ArrayList < Term [ ] > ( ) ; private ArrayList < Integer > positions = new ArrayList < Integer > ( ) ; private int slop = 0 ; public void setSlop ( int s ) { } public int getSlop ( ) { } public void add ( Term term ) { } public void add ( Term [ ] terms ) { } public void add ( Term [ ] terms , int position ) { } public List < Term [ ] > getTermArrays ( ) { } public int [ ] getPositions ( ) { } @ Override public void extractTerms ( Set < Term > terms ) { } private class MultiPhraseWeight extends Weight { private final Similarity similarity ; private final SimWeight stats ; private final Map < Term , TermContext > termContexts = new HashMap < Term , TermContext > ( ) ; public MultiPhraseWeight ( IndexSearcher searcher ) throws IOException { } @ Override public Query getQuery ( ) { } @ Override public float getValueForNormalization ( ) { } @ Override public void normalize ( float queryNorm , float topLevelBoost ) { } @ Override public Scorer scorer ( AtomicReaderContext context , boolean scoreDocsInOrder , boolean topScorer , Bits acceptDocs ) throws IOException { assert ! ( termArrays . isEmpty ( ) ) ; final AtomicReader reader = context . reader ( ) ; final Bits liveDocs = acceptDocs ; PhraseQuery [ ] postingsFreqs = new PhraseQuery . PostingsAndFreq [ termArrays . size ( ) ] ; final Terms fieldTerms = reader . terms ( field ) ; if ( fieldTerms == null ) { return null ; } final TermsEnum termsEnum = fieldTerms . iterator ( null ) ; for ( int pos = 0 ; pos < ( postingsFreqs . length ) ; pos ++ ) { Term [ ] terms = termArrays . get ( pos ) ; final DocsAndPositionsEnum postingsEnum ; int docFreq ; if ( ( terms . length ) > 1 ) { postingsEnum = new UnionDocsAndPositionsEnum ( liveDocs , context , terms , termContexts , termsEnum ) ; docFreq = 0 ; for ( int termIdx = 0 ; termIdx < ( terms . length ) ; termIdx ++ ) { final Term term = terms [ termIdx ] ; TermState termState = termContexts . get ( term ) . get ( context . ord ) ; if ( termState == null ) { continue ; } termsEnum . seekExact ( term . bytes ( ) , termState ) ; docFreq += termsEnum . docFreq ( ) ; } if ( docFreq == 0 ) { return null ; } } else { final Term term = terms [ 0 ] ; TermState termState = termContexts . get ( term ) . get ( context . ord ) ; if ( termState == null ) { return null ; } termsEnum . seekExact ( term . bytes ( ) , termState ) ; postingsEnum = termsEnum . docsAndPositions ( liveDocs , null , 0 ) ; if ( postingsEnum == null ) { <START_BUG> assert ( termsEnum . docs ( liveDocs , null , 0 ) ) != null : "termstate<seq2seq4repair_space>found<seq2seq4repair_space>but<seq2seq4repair_space>no<seq2seq4repair_space>term<seq2seq4repair_space>exists<seq2seq4repair_space>in<seq2seq4repair_space>reader" ; <END_BUG> throw new IllegalStateException ( ( ( ( ( "field<seq2seq4repair_space>\"" + ( term . field ( ) ) ) + "\"<seq2seq4repair_space>was<seq2seq4repair_space>indexed<seq2seq4repair_space>without<seq2seq4repair_space>position<seq2seq4repair_space>data;<seq2seq4repair_space>cannot<seq2seq4repair_space>run<seq2seq4repair_space>PhraseQuery<seq2seq4repair_space>(term=" ) + ( term . text ( ) ) ) + ")" ) ) ; } docFreq = termsEnum . docFreq ( ) ; } postingsFreqs [ pos ] = new PhraseQuery . PostingsAndFreq ( postingsEnum , docFreq , positions . get ( pos ) . intValue ( ) , terms ) ; } if ( ( slop ) == 0 ) { ArrayUtil . mergeSort ( postingsFreqs ) ; } if ( ( slop ) == 0 ) { ExactPhraseScorer s = new ExactPhraseScorer ( this , postingsFreqs , similarity . exactSimScorer ( stats , context ) ) ; if ( s . noDocs ) { return null ; } else { return s ; } } else { return new SloppyPhraseScorer ( this , postingsFreqs , slop , similarity . sloppySimScorer ( stats , context ) ) ; } } @ Override public Explanation explain ( AtomicReaderContext context , int doc ) throws IOException { } } @ Override public Query rewrite ( IndexReader reader ) { } @ Override public Weight createWeight ( IndexSearcher searcher ) throws IOException { } @ Override public final String toString ( String f ) { } @ Override public boolean equals ( Object o ) { } @ Override public int hashCode ( ) { } private int termArraysHashCode ( ) { } private boolean termArraysEquals ( List < Term [ ] > termArrays1 , List < Term [ ] > termArrays2 ) { } }

Fix:
assert ( termsEnum . docs ( liveDocs , null , false ) ) != null : "termstate<seq2seq4repair_space>found<seq2seq4repair_space>but<seq2seq4repair_space>no<seq2seq4repair_space>term<seq2seq4repair_space>exists<seq2seq4repair_space>in<seq2seq4repair_space>reader" ;