Source:
public void getChildrenCounts(List<BriefObjectMetadata> resultList, AccessGroupSet accessGroups, String countName, String queryAddendum, SolrQuery baseQuery) { long startTime = System.currentTimeMillis(); if (resultList == null || resultList.size() == 0) return; String ancestorPathField = solrSettings.getFieldName(SearchFieldKeys.ANCESTOR_PATH.name()); SolrQuery solrQuery; if (baseQuery == null) { solrQuery = new SolrQuery(); StringBuilder query = new StringBuilder("*:*"); try { addAccessRestrictions(query, accessGroups); } catch (AccessRestrictionException e) { LOG.error(e.getMessage()); return; } solrQuery.setStart(0); solrQuery.setRows(0); solrQuery.setQuery(query.toString()); } else { solrQuery = baseQuery.getCopy(); solrQuery.setRows(0); if (solrQuery.getFacetFields() != null) { for (String facetField : solrQuery.getFacetFields()) { solrQuery.removeFacetField(facetField); } } } if (queryAddendum != null) { solrQuery.setQuery(solrQuery.getQuery() + " AND " + queryAddendum); } solrQuery.setFacet(true); solrQuery.setFacetMinCount(1); solrQuery.addFacetField(ancestorPathField); solrQuery.add("f." + ancestorPathField + ".facet.limit", Integer.toString(Integer.MAX_VALUE)); solrQuery.setFacetSort("index"); LOG.warn("This is the one you're looking for!" + solrQuery.toString()); try { startTime = System.currentTimeMillis(); QueryResponse queryResponse = this.executeQuery(solrQuery); LOG.info("Query executed in " + (System.currentTimeMillis() - startTime)); assignChildrenCounts(queryResponse.getFacetField(ancestorPathField), resultList, countName); } catch (SolrServerException e) { LOG.error("Error retrieving Solr search result request", e); } }

Target:
public void getChildrenCounts(List<BriefObjectMetadata> resultList, AccessGroupSet accessGroups, String countName, String queryAddendum, SolrQuery baseQuery) { long startTime = System.currentTimeMillis(); if (resultList == null || resultList.size() == 0) return; String ancestorPathField = solrSettings.getFieldName(SearchFieldKeys.ANCESTOR_PATH.name()); SolrQuery solrQuery; if (baseQuery == null) { solrQuery = new SolrQuery(); StringBuilder query = new StringBuilder("*:*"); try { addAccessRestrictions(query, accessGroups); } catch (AccessRestrictionException e) { LOG.error(e.getMessage()); return; } solrQuery.setStart(0); solrQuery.setRows(0); solrQuery.setQuery(query.toString()); } else { solrQuery = baseQuery.getCopy(); solrQuery.setRows(0); if (solrQuery.getFacetFields() != null) { for (String facetField : solrQuery.getFacetFields()) { solrQuery.removeFacetField(facetField); } } } if (queryAddendum != null) { solrQuery.setQuery(solrQuery.getQuery() + " AND " + queryAddendum); } solrQuery.setFacet(true); solrQuery.setFacetMinCount(1); solrQuery.addFacetField(ancestorPathField); solrQuery.add("f." + ancestorPathField + ".facet.limit", Integer.toString(Integer.MAX_VALUE)); solrQuery.setFacetSort("index"); try { startTime = System.currentTimeMillis(); QueryResponse queryResponse = this.executeQuery(solrQuery); LOG.info("Query executed in " + (System.currentTimeMillis() - startTime)); assignChildrenCounts(queryResponse.getFacetField(ancestorPathField), resultList, countName); } catch (SolrServerException e) { LOG.error("Error retrieving Solr search result request", e); } }