如: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. }

最新文章

  1. android 决解启动屏白黑屏会延迟几秒的问题
  2. Ubuntu下Nutch1.2的使用
  3. [Android Pro] Android性能优化典范第一季
  4. Linux驱动开发学习笔记(1):LINUX驱动版本的hello world
  5. 该如何理解AMD ,CMD,CommonJS规范--javascript模块化加载学习总结
  6. 窗口类型(Widget, Window, Dialog, Desktop, SubWindow等等)
  7. 在线快速生成 CSS Sptite 的网站
  8. 发短信的主要代码(SmsManger)
  9. Codeforces Round #328 (Div. 2) C. The Big Race 数学.lcm
  10. JavaScript高级程序设计60.pdf
  11. poj-3895-Cycles of Lanes 简单DFS
  12. POJ3254(入门状态压缩dp)
  13. C语言缓冲区(缓存)详解
  14. 拇指玩」制作的「谷歌安装器」app
  15. 谈一谈从 Delphi 2009 之后就支援的重要功能 – 泛型 (Generic)
  16. ASP.NET Core 入门教程 8、ASP.NET Core + Entity Framework Core 数据访问入门
  17. Azure中block和Page的比较 Azure: Did You Know? Block vs Page Blobs
  18. python学习笔记(5)-time库的使用
  19. J2EE十三个技术规范
  20. Spring-MVC依赖

热门文章

  1. (转)android客户端从服务器端获取json数据并解析的实现代码
  2. (转)[老老实实学WCF] 第四篇 初探通信--ChannelFactory
  3. silverlight visifire控件图表制作——silverlight 后台方法ControlChart.xaml.cs
  4. 17 java 存在的问题(转)
  5. 重写String类,也有些区别,供参考
  6. jvm的client和server
  7. keil 中用函数指针调用函数的参数限制
  8. C# 调用外部程序,并获取输出和错误信息
  9. STL适配器的初步理解
  10. WEB打印插件Lodop