Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solr/Solrj: How can I determine the total number of documents in an index?

Tags:

solr

lucene

solrj

How can I determine the total number of documents in a Solr index using Solrj?

After hours of searching on my own, I actually have an answer (given below); I'm only posting this question so others can find the solution more easily.

like image 763
George Armhold Avatar asked Feb 19 '11 12:02

George Armhold


People also ask

How is Solr index size calculated?

If you are looking for the physical on-disk size of the index, you can look at 'data/index' folder under 'dataDir' per the definition in solrconfig. xml. For eg. in example index, it is example/solr/data/index folder.

Can Solr index Word documents?

A Solr index can accept data from many different sources, including XML files, comma-separated value (CSV) files, data extracted from tables in a database, and files in common file formats such as Microsoft Word or PDF.

How long is Solr indexing?

Full index takes about 40 hours using DB. There are some factors that might slowing you down: Memory.


1 Answers

Here's what I'm using. Is this canonical? Is there a better way?

    SolrQuery q = new SolrQuery("*:*");     q.setRows(0);  // don't actually request any data     return server.query(q).getResults().getNumFound(); 
like image 73
George Armhold Avatar answered Sep 20 '22 11:09

George Armhold