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

爷,独闯天下 提交于 2019-12-03 04:14:10

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();

Your answer of sending the query : is probably the best, most general solution. Especially if you are using SolrCloud. However, there is an alternate solution, the Solr Core Admin API

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!