lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Whitman <brian.whit...@variogr.am>
Subject Re: best way to get number of documents in a Solr index
Date Tue, 15 Jan 2008 20:51:25 GMT

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;
   }



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message