一、facet:
在查询结果后面补充一个统计结果
二、group:
返回一个分组结果
三、返回结果打印
1.group
{responseHeader={status=0,QTime=0,params={q=*,group.limit=2,rows=2,wt=javabin,version=2,group.field=name,group=true}},
grouped={name={matches=200,
groups=[
{groupValue=张三0,doclist={numFound=2,start=0,docs=[SolrDocument{id=4ac66f4a3dff4a96be443e8a7a482e9a, name=张三0, remark=我是张三0, _version_=1631225459861618688}, SolrDocument{id=21829bb0d9a64fb0b7e55e574c97c924, name=张三0, remark=我是张三0, _version_=1631230063150104576}]}},
{groupValue=张三1,doclist={numFound=2,start=0,docs=[SolrDocument{id=571dbc4404b947bca2c5d8e10dbef808, name=张三1, remark=我是张三1, _version_=1631225459861618689}, SolrDocument{id=a4e848c58b6a405595ca2ac557a198f7, name=张三1, remark=我是张三1, _version_=1631230063152201728}]}}]}}}
//设置group.limit=0,可作分组统计
{responseHeader={status=0,QTime=0,params={q=*,group.limit=0,rows=2,wt=javabin,version=2,group.field=name,group=true}},grouped={name={matches=200,groups=[
{groupValue=张三0,doclist={numFound=2,start=0,docs=[]}}, {groupValue=张三1,doclist={numFound=2,start=0,docs=[]}}]}}}
2.facet
{responseHeader={status=0,QTime=0,params={q=*,facet.limit=2,facet.field=[name, remark],facet.mincount=1,facet=true,wt=javabin,version=2}},
response={numFound=200,start=0,docs=[SolrDocument{id=4ac66f4a3dff4a96be443e8a7a482e9a, name=张三0, remark=我是张三0, _version_=1631225459861618688},
SolrDocument{id=571dbc4404b947bca2c5d8e10dbef808, name=张三1, remark=我是张三1, _version_=1631225459861618689},
SolrDocument{id=520f9f4d5f8540dfa255554f5ae2153d, name=张三2, remark=我是张三2, _version_=1631225459861618690},
SolrDocument{id=10412d2522fa40ec8cfc045130ddae56, name=张三3, remark=我是张三3, _version_=1631225459861618691},
SolrDocument{id=a77d3756fec34ca7992bdb649d71ebf4, name=张三4, remark=我是张三4, _version_=1631225459861618692},
SolrDocument{id=98ca3b9d382b46ecb9b42d68f87e7cd9, name=张三5, remark=我是张三5, _version_=1631225459861618693},
SolrDocument{id=2b025281272b40ad9ddefaf2ad985458, name=张三6, remark=我是张三6, _version_=1631225459861618694},
SolrDocument{id=b1853489620d4c3683553e9c3f6d193c, name=张三7, remark=我是张三7, _version_=1631225459861618695},
SolrDocument{id=4397632fefbe4f289b8e943c8eba11b3, name=张三8, remark=我是张三8, _version_=1631225459872104448},
SolrDocument{id=a3725664994a48b79ba3b41e8200b12a, name=张三9, remark=我是张三9, _version_=1631225459872104449}]},
facet_counts={facet_queries={},
facet_fields={name={张三0=2,张三1=2},remark={我是张三0=2,我是张三1=2}},facet_ranges={},facet_intervals={},facet_heatmaps={}}}
{responseHeader={status=0,QTime=0,params={q=*,facet.limit=2,facet.field=[name, remark],facet.mincount=1,rows=0,facet=true,wt=javabin,version=2}},
response={numFound=200,start=0,docs=[]},
facet_counts={facet_queries={},facet_fields={name={张三0=2,张三1=2},remark={我是张三0=2,我是张三1=2}},facet_ranges={},facet_intervals={},facet
四、补充
1.两个方法都可以设置q和fq进行过滤
2.facet是单纯对过滤后的结果进行统计,获取统计值
3.group是根据过滤条件和分组的条件进行分组获取分组结果
4.group应该是将数据读取到内存中时进行的,facet也是
(如有错误:请大家帮忙纠正,谢谢)