Buggy code:
public class TestOmitTf extends LuceneTestCase { public static class SimpleSimilarity extends TFIDFSimilarity { @ Override public float queryNorm ( float sumOfSquaredWeights ) { } @ Override public float coord ( int overlap , int maxOverlap ) { } @ Override public float lengthNorm ( FieldInvertState state ) { } @ Override public float tf ( float freq ) { } @ Override public float sloppyFreq ( int distance ) { } @ Override public float idf ( long docFreq , long numDocs ) { } @ Override public Explanation idfExplain ( CollectionStatistics collectionStats , TermStatistics [ ] termStats ) { } @ Override public float scorePayload ( int doc , int start , int end , BytesRef payload ) { } } private static final FieldType omitType = new FieldType ( TextField . TYPE_NOT_STORED ) ; private static final FieldType normalType = new FieldType ( TextField . TYPE_NOT_STORED ) ; public void testOmitTermFreqAndPositions ( ) throws Exception { } public void testMixedMerge ( ) throws Exception { } public void testMixedRAM ( ) throws Exception { } private void assertNoPrx ( Directory dir ) throws Throwable { } public void testNoPrxFile ( ) throws Throwable { } public void testBasic ( ) throws Exception { Directory dir = newDirectory ( ) ; Analyzer analyzer = new org . apache . lucene . analysis . MockAnalyzer ( random ( ) ) ; IndexWriter writer = new IndexWriter ( dir , newIndexWriterConfig ( TEST_VERSION_CURRENT , analyzer ) . setMaxBufferedDocs ( 2 ) . setSimilarity ( new TestOmitTf . SimpleSimilarity ( ) ) . setMergePolicy ( newLogMergePolicy ( 2 ) ) ) ; StringBuilder sb = new StringBuilder ( 265 ) ; String term = "term" ; for ( int i = 0 ; i < 30 ; i ++ ) { Document d = new Document ( ) ; sb . append ( term ) . append ( "<seq2seq4repair_space>" ) ; String content = sb . toString ( ) ; Field noTf = newField ( "noTf" , ( content + ( ( i % 2 ) == 0 ? "" : "<seq2seq4repair_space>notf" ) ) , TestOmitTf . omitType ) ; d . add ( noTf ) ; Field tf = newField ( "tf" , ( content + ( ( i % 2 ) == 0 ? "<seq2seq4repair_space>tf" : "" ) ) , TestOmitTf . normalType ) ; d . add ( tf ) ; writer . addDocument ( d ) ; } writer . forceMerge ( 1 ) ; writer . close ( ) ; IndexReader reader = DirectoryReader . open ( dir ) ; IndexSearcher searcher = new IndexSearcher ( reader ) ; searcher . setSimilarity ( new TestOmitTf . SimpleSimilarity ( ) ) ; Term a = new Term ( "noTf" , term ) ; Term b = new Term ( "tf" , term ) ; Term c = new Term ( "noTf" , "notf" ) ; Term d = new Term ( "tf" , "tf" ) ; TermQuery q1 = new TermQuery ( a ) ; TermQuery q2 = new TermQuery ( b ) ; TermQuery q3 = new TermQuery ( c ) ; TermQuery q4 = new TermQuery ( d ) ; PhraseQuery pq = new PhraseQuery ( ) ; pq . add ( a ) ; pq . add ( c ) ; try { searcher . search ( pq , 10 ) ; fail ( "did<seq2seq4repair_space>not<seq2seq4repair_space>hit<seq2seq4repair_space>expected<seq2seq4repair_space>exception" ) ; } catch ( IllegalStateException ise ) { } searcher . search ( q1 , new TestOmitTf . CountingHitCollector ( ) { private Scorer scorer ; @ Override public final void setScorer ( Scorer scorer ) { this . scorer = scorer ; } @ Override public final void collect ( int doc ) throws IOException { float score = scorer . score ( ) ; <START_BUG> assertTrue ( ( score == 1.0F ) ) ; <END_BUG> super . collect ( doc ) ; } } ) ; searcher . search ( q2 , new TestOmitTf . CountingHitCollector ( ) { private Scorer scorer ; @ Override public final void setScorer ( Scorer scorer ) { this . scorer = scorer ; } @ Override public final void collect ( int doc ) throws IOException { float score = scorer . score ( ) ; assertEquals ( ( 1.0F + doc ) , score , 1.0E-5F ) ; super . collect ( doc ) ; } } ) ; searcher . search ( q3 , new TestOmitTf . CountingHitCollector ( ) { private Scorer scorer ; @ Override public final void setScorer ( Scorer scorer ) { this . scorer = scorer ; } @ Override public final void collect ( int doc ) throws IOException { float score = scorer . score ( ) ; assertTrue ( ( score == 1.0F ) ) ; assertFalse ( ( ( doc % 2 ) == 0 ) ) ; super . collect ( doc ) ; } } ) ; searcher . search ( q4 , new TestOmitTf . CountingHitCollector ( ) { private Scorer scorer ; @ Override public final void setScorer ( Scorer scorer ) { this . scorer = scorer ; } @ Override public final void collect ( int doc ) throws IOException { float score = scorer . score ( ) ; assertTrue ( ( score == 1.0F ) ) ; assertTrue ( ( ( doc % 2 ) == 0 ) ) ; super . collect ( doc ) ; } } ) ; BooleanQuery bq = new BooleanQuery ( ) ; bq . add ( q1 , MUST ) ; bq . add ( q4 , MUST ) ; searcher . search ( bq , new TestOmitTf . CountingHitCollector ( ) { @ Override public final void collect ( int doc ) throws IOException { super . collect ( doc ) ; } } ) ; assertEquals ( 15 , TestOmitTf . CountingHitCollector . getCount ( ) ) ;

Fix:
assertTrue ( ( "got<seq2seq4repair_space>score=" + score ) , ( score == 1.0F ) ) ;