This started out in the num-docs thread, but deserves its own. And a wiki page.
There is a more complex and general way to get the number of documents in the index. I run a query against solr and postprocess the output with an XSL script. Install this xsl script as home/conf/xslt/numfound.xsl. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:value-of select="response/result/@numFound" /> <xsl:text>
</xsl:text> </xsl:template> </xsl:stylesheet> Make sure 'curl' is installed, and add numfound.sh, a unix shell script. SHARD=localhost:8080/solr QUERY="$1" LINK="http://$SHARD/select?indent=on&version=2.2&q=$QUERY&start=0&rows=0 &fl=*&wt=xslt&tr=numfound.xsl" curl --silent "$LINK" -H "Content-Type:text" -X GET Run it as sh numfound.sh "*:*" How to install the XSLT script is to be found on the Wiki. Star-colon-star is magic for 'all records'. XSL is appalling garbage. Cheers!