question: public void testEmptyIndex ( ) throws Exception { IndexSearcher empty = newSearcher ( new MultiReader ( ) ) ; Query query = new TermQuery ( new Term ( "contents" , "foo" ) ) ; Sort sort = new Sort ( ) ; TopDocs td = empty . search ( query , 10 , sort , true , true ) ; assertEquals ( 0 , td . totalHits ) ; sort . setSort ( SortField . FIELD_DOC ) ; td = empty . search ( query , 10 , sort , true , true ) ; assertEquals ( 0 , td . totalHits ) ; sort . setSort ( new SortField ( "int" , SortField . Type . INT ) , SortField . FIELD_DOC ) ; td = empty . search ( query , 10 , sort , true , true ) ; assertEquals ( 0 , td . totalHits ) ; sort . setSort ( new SortField ( "string" , SortField . Type . STRING , true ) , SortField . FIELD_DOC ) ; td = empty . search ( query , 10 , sort , true , true ) ; assertEquals ( 0 , td . totalHits ) ; sort . setSort ( new SortField ( "string_val" , SortField . Type . STRING_VAL , true ) , SortField . FIELD_DOC ) ; td = empty . search ( query , 10 , sort , true , true ) ; assertEquals ( 0 , td . totalHits ) ; sort . setSort ( new SortField ( "float" , SortField . Type . FLOAT ) , new SortField ( "string" , SortField . Type . STRING ) ) ; td = empty . search ( query , 10 , sort , true , true ) ; assertEquals ( 0 , td . totalHits ) ; }
target:  test sorts when there's nothing in the index 