@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; }
private void extractGroupedInfo( NamedList<Object> info ) { if ( info != null ) { _groupResponse = new GroupResponse(); int size = info.size(); for (int i=0; i < size; i++) { _groupResponse.add(groupedCommand); } else if (queryCommand != null) { Integer iMatches = (Integer) oMatches; _groupResponse.add(groupCommand);
private void extractGroupedInfo( NamedList<Object> info ) { if ( info != null ) { _groupResponse = new GroupResponse(); int size = info.size(); for (int i=0; i < size; i++) { _groupResponse.add(groupedCommand); } else if (queryCommand != null) { Integer iMatches = (Integer) oMatches; _groupResponse.add(groupCommand);
/** * @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); } }
List<GroupCommand> values = groupResponse.getValues(); for (GroupCommand groupCommand : values) {
values = rsp.getGroupResponse() .getValues() .stream() .filter(g -> g.getName().equals(visitor.getExpression().toString()))
docs = new ArrayList<>(rows); GroupResponse gResponse = response.getGroupResponse(); for (GroupCommand gCommand : gResponse.getValues()) { total += gCommand.getNGroups(); for (Group group : gCommand.getValues()) {