I have the following:
43 documents indexed in Solr
If I use the Java API to execute a request without any grouping, for example:
SolrQuery query = new SolrQuery("*:*"); query.setRows(10);
Then I can get the total number of matching elements:
solrServer.query(query).getResults().getNumFound(); //43 in this case
The getResults() method returns an instance of SolrDocumentList that contains this value.
If, however, I use grouping, for example:
query.set("group", "true"); query.set("group.format", "simple"); query.set("group.field", "someField");
Then the above code to get the query results does not work loger (throws NPE), and instead I have to use:
List<GroupCommand> groupCommands = solrServer.query(query).getGroupResponse().getValues(); List<Group> groups = groupCommand.getValues(); Group group = groups.get(groupIndex);
I donβt understand how to use this part of the API to get the total number of relevant documents (43 from the non-group request above). At first I thought it was already impossible to get this with grouping, but I noticed that if I make a similar request in the Solr admin console, with the same grouping and everything, it will return the same results as the Java API and also numFound=43 . Thus, it is obvious that the code used for the console has some way to get this value even when using grouping:

My question is, how can I get this total number of matching documents for a query using grouping done through the Solr Java API?