: In my Solr 6.6 based code, I have the following line that get the total : number of documents in a collection: : : totalDocs=indexSearcher.getStatistics().get("numDocs")) ... : With Solr 7.2.1, 'getStatistics' is no longer available, and it seems that : it is replaced by 'collectionStatistics' or 'termStatistics': ... : So my questions is what is the equivalent statement in solr 7.2.1? Is it: : : solrIndexSearcher.collectionStatistics("numDocs").maxDoc();
Uh... no. that's not quite true. In the 6.x code line, getStatistics() was part of the SolrInfoMBean API that SolrIndexSearcher and many other Solr objects implemented... http://lucene.apache.org/solr/6_6_0/solr-core/org/apache/solr/search/SolrIndexSearcher.html#getStatistics-- In 7.0, SolrInfoMBean was replaced with SolrInfoBean as part ofthe switch over to the new more robust the Metrics API... https://lucene.apache.org/solr/guide/7_0/major-changes-in-solr-7.html#jmx-support-and-mbeans https://lucene.apache.org/solr/guide/7_0/metrics-reporting.html http://lucene.apache.org/solr/7_0_0/solr-core/org/apache/solr/core/SolrInfoBean.html (The collectionStatistics() and termStatistics() methods are lower level Lucene concepts) IIRC The closest 7.x equivilent to "indexSearcher.getStatistics()" is "indexSearcher.getMetricsSnapshot()" ... but the keys in that map will have slightly diff/longer names then they did before, you can use "indexSearcher.getMetricNames()" so see the full list. ...but frankly that's all a very comlicated way to get "numDocs" if you're writting a solr plugin that has direct access to a SolrIndexSearcher instance ... you can just call "solrIndexSearcher.numDocs()" method and make your life a lot simpler. -Hoss http://www.lucidworks.com/