Thanks a lot Brian!
Maria

Brian Whitman wrote:

On Jan 15, 2008, at 3:47 PM, Maria Mosolova wrote:

Hello,

I am looking for the best way to get the number of documents in a Solr index. I'd like to do it from a java code using solrj.


  public int resultCount() {
    try {
      SolrQuery q = new SolrQuery("*:*");
      QueryResponse rq = solr.query(q);
      return rq.getResults().getNumFound();
    } catch (org.apache.solr.client.solrj.SolrServerException e) {
      System.err.println("Query problem");
    } catch (java.io.IOException e)  {
      System.err.println("Other error");
    }
    return -1;
  }




Reply via email to