solr group

Group参数:

参数类型说明
group布尔值设为true,表示结果需要分组
group.field字符串需要分组的字段,字段类型需要时是StrField或TextField
group.func查询语句可以指定查询函数
group.query查询语句可以指定查询语句
rows整数返回多少组结果,默认10
start整数指定结果开始位置/偏移量
group.limit整数每组返回多数条结果,默认1
group.offset整数指定每组结果开始位置/偏移量
sort排序算法控制各个组的返回顺序
group.sort排序算法控制每一分组内部的顺序
group.formatgrouped/simple设置为simple可以使得结果以单一列表形式返回
group.main布尔值设为true时,结果将主要由第一个字段的分组命令决定
group.ngroups布尔值设为true时,Solr将返回分组数量,默认fasle
group.truncate布尔值设为true时,facet数量将基于group分组中匹相关性高的文档,默认fasle
group.cache.percent整数0-100设为大于0时,表示缓存结果,默认为0。该项对于布尔查询,通配符查询,模糊查询有改善,却会减慢普通词查询。

 

示例:参数加上group=truegroup.ngroups=truegroup.field=post_timegroup.limit=3

说明:以post_time分组,每个分组返回三条记录,group.ngroups=true,返回分组数量

返回:

{
  "responseHeader":{
    "status":0,
    "QTime":18,
    "params":{
      "q":"post_content:\"nike\"",
      "indent":"on",
      "fl":"id,post_time",
      "group.limit":"3",
      "group.ngroups":"true",
      "rows":"3",
      "wt":"json",
      "group.field":"post_time",
      "_":"1567574501345",
      "group":"true"}},
  "grouped":{
    "post_time":{
      "matches":33679,
      "ngroups":1563,
      "groups":[{
          "groupValue":"20190226",
          "doclist":{"numFound":70,"start":0,"docs":[
              {
                "id":"15874598",
                "post_time":"20190226"},
              {
                "id":"15862891",
                "post_time":"20190226"},
              {
                "id":"15862897",
                "post_time":"20190226"}]
          }},
        {
          "groupValue":"20190418",
          "doclist":{"numFound":72,"start":0,"docs":[
              {
                "id":"17550386",
                "post_time":"20190418"},
              {
                "id":"17530801",
                "post_time":"20190418"},
              {
                "id":"17530802",
                "post_time":"20190418"}]
          }},
        {
          "groupValue":"20190509",
          "doclist":{"numFound":64,"start":0,"docs":[
              {
                "id":"18440190",
                "post_time":"20190509"},
              {
                "id":"18477522",
                "post_time":"20190509"},
              {
                "id":"18465154",
                "post_time":"20190509"}]
          }}]}}}

 

最新回复(0)
/jishuAZJYlHSrTg_2FpWlcwyjz0C1nC0DLuVXimzmzDNdT4MmM_3D4858490
8 简首页