@Override public List<SolrDocument> getResponseDocuments(QueryResponse response) { List<SolrDocument> docs; if (response.getGroupResponse() == null) { docs = response.getResults(); } else { docs = new ArrayList<SolrDocument>(); GroupResponse gr = response.getGroupResponse(); for (GroupCommand gc : gr.getValues()) { for (Group g : gc.getValues()) { for (SolrDocument d : g.getResult()) { docs.add(d); } } } } return docs; }
/** * @param query the {@link SolrQuery} * @param consumer how to handle the results * @param groupingField the name of the field to group with * @param groupLimit the number of results per group */ public void group(SolrQuery query, Consumer<GroupCommand> consumer, String groupingField, int groupLimit) { if (query == null) throw new NullPointerException("Search query is null"); if (groupingField == null) throw new NullPointerException("Grouping field is null"); LOGGER.info("query {}", query.toQueryString()); query.setRows(this._row); query.setStart(this._start); // grouping query.setParam("group", true); //the number of groups that matches the the query query.setParam("group.ngroups", true); // the grouping field query.setParam("group.field", groupingField); // number of group limit query.setParam("group.limit", String.valueOf(groupLimit)); QueryResponse response = this._solr.query(query); if (response != null) { LOGGER.info("response size {}", response.getResponse().size()); GroupResponse groupResponse = response.getGroupResponse(); groupResponse.getValues().forEach(consumer); } }
long total = 0; if (response.getGroupResponse() != null) { docs = new ArrayList<>(rows); GroupResponse gResponse = response.getGroupResponse(); for (GroupCommand gCommand : gResponse.getValues()) { total += gCommand.getNGroups();
static <T> Map<Object, GroupResult<T>> convertGroupQueryResponseToGroupResultMap(Query query, Map<String, Object> objectNames, QueryResponse response, SolrTemplate solrTemplate, Class<T> clazz) { GroupResponse groupResponse = response.getGroupResponse();
QueryResponse rsp = solrServer.query(q); values = rsp.getGroupResponse() .getValues() .stream()