public void testOmitTF() throws Exception {
  Directory dir=newDirectory();
  RandomIndexWriter iw=new RandomIndexWriter(random(),dir);
  Document doc=new Document();
  FieldType ft=new FieldType(TextField.TYPE_NOT_STORED);
  ft.setIndexOptions(IndexOptions.DOCS);
  ft.freeze();
  Field f=newField("foo","bar",ft);
  doc.add(f);
  iw.addDocument(doc);
  IndexReader ir=iw.getReader();
  iw.close();
  IndexSearcher is=newSearcher(ir);
  for (  Similarity sim : sims) {
    is.setSimilarity(sim);
    BooleanQuery.Builder query=new BooleanQuery.Builder();
    query.add(new TermQuery(new Term("foo","bar")),BooleanClause.Occur.SHOULD);
    assertEquals(1,is.search(query.build(),10).totalHits);
  }
  ir.close();
  dir.close();
}

public void testOmitTF ( ) throws Exception { Directory dir = newDirectory ( ) ; RandomIndexWriter iw = new RandomIndexWriter ( random ( ) , dir ) ; Document doc = new Document ( ) ; FieldType ft = new FieldType ( TextField . TYPE_NOT_STORED ) ; ft . setIndexOptions ( IndexOptions . DOCS ) ; ft . freeze ( ) ; Field f = newField ( "foo" , "bar" , ft ) ; doc . add ( f ) ; iw . addDocument ( doc ) ; IndexReader ir = iw . getReader ( ) ; iw . close ( ) ; IndexSearcher is = newSearcher ( ir ) ; for ( Similarity sim : sims ) { is . setSimilarity ( sim ) ; BooleanQuery . Builder query = new BooleanQuery . Builder ( ) ; query . add ( new TermQuery ( new Term ( "foo" , "bar" ) ) , BooleanClause . Occur . SHOULD ) ; assertEquals ( 1 , is . search ( query . build ( ) , 10 ) . totalHits ) ; } ir . close ( ) ; dir . close ( ) ; }
make sure all sims work if tf is omitted
