如:http://localhost:8080/solr/test_core/select?q=*:*&wt=json&indent=true&group=true&group.field=field&group.limit=0

参数说明

param name

param value

description

group

true/false

if true, turn on result grouping

group.field

[fieldname]

Group based on the unique values of a field. The field must currently be single-valued and must be either indexed, or be another field type that has a value source and works in a function query - such as ExternalFileField. Note: for Solr 3.x versions the field must by a string like field such as StrField or TextField, otherwise a http status 400 is returned.

group.func

[function query]

Group based on the unique values of a function query.  Solr4.0 This parameter only is supported on 4.0

group.query

[query]

Return a single group of documents that also match the given query.

rows

[number]

The number of groups to return. Defaults to 10.

start

[number]

The offset into the list of groups.

group.limit

[number]

The number of results (documents) to return for each group. Defaults to 1.

group.offset

[number]

The offset into the document list of each group.

sort

[sortspec]

How to sort the groups relative to each other. For example, sort=popularity desc will cause the groups to be sorted according to the highest popularity doc in each group. Defaults to "score desc".

group.sort

[sortspec]

How to sort documents within a single group. Defaults to the same value as the sort parameter.

group.format

grouped/simple

if simple, the grouped documents are presented in a single flat list. The start and rows parameters refer to numbers of documents instead of numbers of groups.

group.main

true/false

If true, the result of the last field grouping command is used as the main result list in the response, using group.format=simple

group.ngroups

true/false

If true, includes the number of groups that have matched the query. Default is false.  Solr4.1
WARNING: If this parameter is set to true on a sharded environment, all the documents that belong to the same group have to be located in the same shard, otherwise the count will be incorrect. If you are using SolrCloud, consider using "custom hashing"

group.truncate

true/false

If true, facet counts are based on the most relevant document of each group matching the query. Same applies for StatsComponent. Default is false.  Solr3.4 Supported from Solr 3.4 and up.

group.facet

true/false

Whether to compute grouped facets for the field facets specified in facet.field parameters. Grouped facets are computed based on the first specified group. Just like normal field faceting, fields shouldn't be tokenized (otherwise counts are computed for each token). Grouped faceting supports single and multivalued fields. Default is false.  Solr4.0
WARNING: If this parameter is set to true on a sharded environment, all the documents that belong to the same group have to be located in the same shard, otherwise the count will be incorrect. If you are using SolrCloud, consider using "custom hashing"

group.cache.percent

[0-100]

If > 0 enables grouping cache. Grouping is executed actual two searches. This option caches the second search. A value of 0 disables grouping caching. Default is 0. Tests have shown that this cache only improves search time with boolean queries, wildcard queries and fuzzy queries. For simple queries like a term query or a match all query this cache has a negative impact on performance

Solrj检索代码:

    1. SolrServer server = this.getSolrServer();
    2. SolrQuery param = new SolrQuery();
    3. param.setQuery(QUERY_CONTENT);
    4. param.setRows(QUERY_ROWS);
    5. param.setParam(GroupParams.GROUP, GROUP);
    6. param.setParam(GroupParams.GROUP_FIELD, GROUP_FIELD);
    7. param.setParam(GroupParams.GROUP_LIMIT, GROUP_LIMIT);
    8. QueryResponse response = null;
    9. try {
    10. response = server.query(param);
    11. } catch (SolrServerException e) {
    12. logger.error(e.getMessage(), e);
    13. }
    14. Map<String, Integer> info = new HashMap<String, Integer>();
    15. GroupResponse groupResponse = response.getGroupResponse();
    16. if(groupResponse != null) {
    17. List<GroupCommand> groupList = groupResponse.getValues();
    18. for(GroupCommand groupCommand : groupList) {
    19. List<Group> groups = groupCommand.getValues();
    20. for(Group group : groups) {
    21. info.put(group.getGroupValue(), (int)group.getResult().getNumFound());
    22. }
    23. }
    24. }

solr group分组查询的更多相关文章

  1. SQL group 分组查询

    1.使用group by进行分组查询  在使用group by关键字时,在select列表中可以指定的项目是有限制的,select语句中仅许以下几项:  被分组的列 为每个分组返回一个值得表达式,例如 ...

  2. Spring Data Solr的分组查询 for 搜索面板的商品分类

    private List searchCategoryList(Map searchMap) { SimpleQuery query = new SimpleQuery(new Criteria(&q ...

  3. Solr分组查询

     项目中需要实时的返回一下统计的东西,因此就要进行分组,在获取一些东西,代码拿不出来,因此分享一篇,还是很使用的. facet搜索 /** * * 搜索功能优化-关键词搜索 * 搜索范围:商品名称.店 ...

  4. SQL分组查询group by

    注意:select 后的字段,必须要么包含在group by中,要么包含在having 后的聚合函数里. 1. GROUP BY 是分组查询, 一般 GROUP BY 是和聚合函数配合使用 group ...

  5. SQL group by分组查询(转)

    本文导读:在实际SQL应用中,经常需要进行分组聚合,即将查询对象按一定条件分组,然后对每一个组进行聚合分析.创建分组是通过GROUP BY子句实现的.与WHERE子句不同,GROUP BY子句用于归纳 ...

  6. .Net程序员学用Oracle系列(21):分组查询(GROUP BY)

    1.GROUP BY 标准分组 1.1.GROUP BY 概述 1.2.WHERE 和 HAVING 的区别? 2.GROUP BY 扩展分组 2.1.ROLLUP 分组 2.2.CUBE 分组 2. ...

  7. Oracle和MySQL分组查询GROUP BY

    Oracle和MySQL分组查询GROUP BY 真题1.Oracle和MySQL中的分组(GROUP BY)有什么区别? 答案:Oracle对于GROUP BY是严格的,所有要SELECT出来的字段 ...

  8. T-SQL GROUP BY子句 分组查询

    SQL Server GROUP BY子句与SELECT语句协作使用,以将相同的数据分组. GROUP BY子句位于SELECT语句中的WHERE子句之后,位于ORDER BY子句之前. 语法 以下是 ...

  9. Mysql分组查询group by语句详解

    (1) group by的含义:将查询结果按照1个或多个字段进行分组,字段值相同的为一组(2) group by可用于单个字段分组,也可用于多个字段分组 select * from employee; ...

随机推荐

  1. EF中加载实体的方式

    EF中的查询执行时机:1. foreach进行枚举2. ToArray.ToList.ToDictionary3. Linq的一些操作,如First.Any4. DbSet上的Load操作.DbEnt ...

  2. C# viewstate

    Viewstate 处理不是form中可以传值的标签 进行传值.可以禁用元素的viewstate 也可以禁用页面的Enableviewstate=”false”;(在配置区域写)内网系统,互联网后台可 ...

  3. system进程启动普通用户进程调研

    system进程启动普通用户进程 关键函数是CreateProcessAsUser 主要思路是先取得目的用户的token,然后用上面的函数启动 1.从explorer中取token BOOL GetT ...

  4. MDX示例:求解中位数、四分位数(median、quartile)

    一个人力资源咨询集团通过网络爬虫采集手段将多个知名招聘网站上发布的求职和招聘等信息准实时采集到自己的库里,形成一个数据量浩大的招聘信息库,跟踪全国招聘和求职的行业.工种.职位.待遇等信息,并通过商业智 ...

  5. C++ 使用cl命令编辑时发生的问题收录

    1.cl不是内部或这外部命令,也不是可运行的程序或批处理文件. 这个问题的出现的原因是因为系统找不到cl命令处理程序,无法识别,解决办法: 首先在C盘查找cl.exe,可能会查到多个,先选择第一个,将 ...

  6. mac删除顽固图标

    cd  /Users/shelley/Library/Application\ Support/Dock cp  10CCA448-0975-41DE-B47A-8E89FD634227.db  10 ...

  7. Linux_Shell type

    Recommendation is to use the bash shell, because he is strong enough, and absorbed the useful proper ...

  8. C# LinkButton 带参数的OnCommand事件的写法

    前台: <asp:TemplateField HeaderText ="操作"> <HeaderStyle HorizontalAlign ="Cent ...

  9. ftp和http转参数的使用(转)

    浏览器因特网资源:URL是浏览器寻找信息时所需的资源位置,通过URL,应用程序才能找到并使用共享因特网上大量的数据资源. 大部分URL都遵循一种标准的格式: ①HTTP协议(http://或者http ...

  10. ASCII码、base64编码 为什么有的代码要用 base64 进行编码?

    百度百科 ASCII码:http://baike.baidu.com/link?url=bNtzytBhlSUt_l3pwpfICxCxqgAfqsBMaeWX6QF7gH46Tg4pQtKM2aAV ...