private NamedList rQuery(int expectedDocCount,String query,SolrServer server) throws Exception {
  int timeSlept=0;
  NamedList res=query(query,server);
  while (expectedDocCount != numFound(res) && timeSlept < 30000) {
    log.info("Waiting for " + expectedDocCount + " docs");
    timeSlept+=100;
    Thread.sleep(100);
    res=query(query,server);
  }
  log.info("Waited for {}ms and found {} docs",timeSlept,numFound(res));
  return res;
}

private NamedList rQuery ( int expectedDocCount , String query , SolrServer server ) throws Exception { int timeSlept = 0 ; NamedList res = query ( query , server ) ; while ( expectedDocCount != numFound ( res ) && timeSlept < 30000 ) { log . info ( "Waiting for " + expectedDocCount + " docs" ) ; timeSlept += 100 ; Thread . sleep ( 100 ) ; res = query ( query , server ) ; } log . info ( "Waited for {}ms and found {} docs" , timeSlept , numFound ( res ) ) ; return res ; }
will sleep up to 30 seconds , looking for expecteddoccount
