Buggy code:
public class TestDisjunctionMaxQuery extends LuceneTestCase { public static final float SCORE_COMP_THRESH = 0.0F ; private static class TestSimilarity extends DefaultSimilarity { public TestSimilarity ( ) { } public float tf ( float freq ) { } public float lengthNorm ( String fieldName , int numTerms ) { } public float idf ( int docFreq , int numDocs ) { } } public Similarity sim = new TestDisjunctionMaxQuery . TestSimilarity ( ) ; public Directory index ; public IndexReader r ; public IndexSearcher s ; public void setUp ( ) throws Exception { super . setUp ( ) ; index = new RAMDirectory ( ) ; IndexWriter writer = new IndexWriter ( index , new WhitespaceAnalyzer ( ) , true , MaxFieldLength . LIMITED ) ; writer . setSimilarity ( sim ) ; { Document d1 = new Document ( ) ; d1 . add ( new org . apache . lucene . document . Field ( "id" , "d1" , Store . YES , Index . NOT_ANALYZED ) ) ; d1 . add ( new org . apache . lucene . document . Field ( "hed" , "elephant" , Store . YES , Index . ANALYZED ) ) ; d1 . add ( new org . apache . lucene . document . Field ( "dek" , "elephant" , Store . YES , Index . ANALYZED ) ) ; writer . addDocument ( d1 ) ; } { Document d2 = new Document ( ) ; d2 . add ( new org . apache . lucene . document . Field ( "id" , "d2" , Store . YES , Index . NOT_ANALYZED ) ) ; d2 . add ( new org . apache . lucene . document . Field ( "hed" , "elephant" , Store . YES , Index . ANALYZED ) ) ; d2 . add ( new org . apache . lucene . document . Field ( "dek" , "albino" , Store . YES , Index . ANALYZED ) ) ; d2 . add ( new org . apache . lucene . document . Field ( "dek" , "elephant" , Store . YES , Index . ANALYZED ) ) ; writer . addDocument ( d2 ) ; } { Document d3 = new Document ( ) ; d3 . add ( new org . apache . lucene . document . Field ( "id" , "d3" , Store . YES , Index . NOT_ANALYZED ) ) ; d3 . add ( new org . apache . lucene . document . Field ( "hed" , "albino" , Store . YES , Index . ANALYZED ) ) ; d3 . add ( new org . apache . lucene . document . Field ( "hed" , "elephant" , Store . YES , Index . ANALYZED ) ) ; writer . addDocument ( d3 ) ; } { Document d4 = new Document ( ) ; d4 . add ( new org . apache . lucene . document . Field ( "id" , "d4" , Store . YES , Index . NOT_ANALYZED ) ) ; d4 . add ( new org . apache . lucene . document . Field ( "hed" , "albino" , Store . YES , Index . ANALYZED ) ) ; d4 . add ( new org . apache . lucene . document . Field ( "hed" , "elephant" , Store . YES , Index . ANALYZED ) ) ; d4 . add ( new org . apache . lucene . document . Field ( "dek" , "albino" , Store . YES , Index . ANALYZED ) ) ; writer . addDocument ( d4 ) ; } writer . close ( ) ; <START_BUG> r = IndexReader . open ( index ) ; <END_BUG> s = new IndexSearcher ( r ) ; s . setSimilarity ( sim ) ; } public void testSkipToFirsttimeMiss ( ) throws IOException { } public void testSkipToFirsttimeHit ( ) throws IOException { } public void testSimpleEqualScores1 ( ) throws Exception { } public void testSimpleEqualScores2 ( ) throws Exception { } public void testSimpleEqualScores3 ( ) throws Exception { } public void testSimpleTiebreaker ( ) throws Exception { } public void testBooleanRequiredEqualScores ( ) throws Exception { } public void testBooleanOptionalNoTiebreaker ( ) throws Exception { } public void testBooleanOptionalWithTiebreaker ( ) throws Exception { } public void testBooleanOptionalWithTiebreakerAndBoost ( ) throws Exception { } protected Query tq ( String f , String t ) { } protected Query tq ( String f , String t , float b ) { } protected void printHits ( String test , ScoreDoc [ ] h , Searcher searcher ) throws Exception { } }

Fix:
r = IndexReader . open ( index , true ) ;