The concept of solr advanced group

Group is similar to Facet

Group and Facet. It is used for grouping. Facet returns all relevant results and allows the user to redefine the result set based on the facet's directory. Facet can filter the number of groups, as well as sorting, date range, and time range grouping, but if you want to get specific data, you need to query one or more times. Group can get the number of groups grouped, one request, you can get all the data. Group and Facet can be used together, but only facet.field and facet.range, date date and dimension statistics are not supported. pivot faceting.

Group Parameter

Parameters 说明
group 布尔值 Set to true, indicating that the result needs to be grouped
group.field string Type needs to be StrField or TextField
group.func query statement can specify the query function
group.query Query statement can specify the query statement
rows integer return how many groups of results, the default 10
start integer Specify the result start position / offset
group.limit integer Each group returns the majority of the results, the default 1
group.offset integer specifies the start of each group of results Position/Offset
sort Sort Algorithm Control the return order of each group
group.sort Sort algorithm Control the order inside each group
group.format grouped/simple Set to simple to make the result a single When the list form returns
group.main 布尔值 is set to true, the result will be determined mainly by the grouping command of the first field.
group.ngroups 布尔值 is set to true, Solr will return the number of packets. , the default fasle
group.truncate 布尔值 is set to true, the number of facets will be based on gro The document with high correlation in the up group, the default fasle
group.cache.percent integer 0-100 is set to be greater than 0, indicating the cache result, the default is 0. For Boolean queries, wildcard queries, fuzzy queries have improved, but will slow down ordinary word queries.

public void SearchGroup(String QUERY_CONTENT,int QUERY_ROWS, Boolean GROUP, String GROUP_FIELD,String GROUP_LIMIT) {          SolrServer server = createSolrServer();            SolrQuery param = new SolrQuery();            param.setQuery("jobsName:"+QUERY_CONTENT);            param.setRows(QUERY_ROWS);            param.setParam(GroupParams.GROUP, GROUP);            param.setParam(GroupParams.GROUP_FIELD, GROUP_FIELD);                    param.setParam(GroupParams.GROUP_LIMIT, GROUP_LIMIT);            QueryResponse response = null;            try {                response = server.query(param);            } catch (SolrServerException e) {               // logger.error(e.getMessage(), e);            }            Map<String, Integer> info = new HashMap<String, Integer>();            GroupResponse groupResponse = response.getGroupResponse();            if(groupResponse != null) {                List<GroupCommand> groupList = groupResponse.getValues();                for(GroupCommand groupCommand : groupList) {                    List<Group> groups = groupCommand.getValues();                    for(Group group : groups) {                        info.put(group.getGroupValue(), (int)group.getResult().getNumFound());                       System.out.println(group.getGroupValue()+"---"+group.getResult().getNumFound());                  }                }            }       }