【问题标题】:How to do facet group query on Apache solr如何在 Apache solr 上进行构面组查询
【发布时间】:2012-07-29 04:31:36
【问题描述】:

我正在对 solr 进行构面查询。它为我提供了构面及其每个项目的计数...但是现在我想对构面执行组查询。这使我根据组进行计数...

示例

以下是数据

Item1:耐克鞋(尺码:8,9,10) Item2 : Reebok 鞋款(尺码:8,9,10)

现在在这种情况下,我的品牌方面查询返回如下结果

  • 耐克:3

  • 锐步:3

我需要的结果是

  • 耐克:1
  • 锐步:1

问候

【问题讨论】:

    标签: solr


    【解决方案1】:

    http://1XX.XXX.XXX.XXX:8080/solr/autocomplete/select?q=displayterm:new&wt=json&indent=true&q.op=and&fl=displayterm&group=true&group.field=displayterm

    注意:&group=true&group.field=displayterm
    此响应按 displayterm 分组

    回应:

    {
      "responseHeader":{
        "status":0,
        "QTime":6,
        "params":{
          "fl":"displayterm",
          "indent":"true",
          "q":"displayterm:new",
          "q.op":"and",
          "group.field":"displayterm",
          "group":"true",
          "wt":"json"}},
      "grouped":{
        "displayterm":{
          "matches":231,
          "groups":[{
              "groupValue":null,
              "doclist":{"numFound":220,"start":0,"docs":[
                  {
                    "displayterm":"Professional News"}]
              }},
            {
              "groupValue":"general",
              "doclist":{"numFound":1,"start":0,"docs":[
                  {
                    "displayterm":"General News"}]
              }},
            {
              "groupValue":"delhi",
              "doclist":{"numFound":2,"start":0,"docs":[
                  {
                    "displayterm":"New Delhi"}]
              }},
            {
              "groupValue":"care",
              "doclist":{"numFound":1,"start":0,"docs":[
                  {
                    "displayterm":"New Born Care Week"}]
              }},
            {
              "groupValue":"civil",
              "doclist":{"numFound":1,"start":0,"docs":[
                  {
                    "displayterm":"NEW CIVIL HOSPITAL, SURAT"}]
              }},
            {
              "groupValue":"blood",
              "doclist":{"numFound":1,"start":0,"docs":[
                  {
                    "displayterm":"Newlife Blood Bank"}]
              }},
            {
              "groupValue":"college",
              "doclist":{"numFound":1,"start":0,"docs":[
                  {
                    "displayterm":"New Medical College Hospital"}]
              }},
            {
              "groupValue":"degree",
              "doclist":{"numFound":1,"start":0,"docs":[
                  {
                    "displayterm":"Homeopathy(Degree Course) Regulation New"}]
              }},
            {
              "groupValue":"child",
              "doclist":{"numFound":1,"start":0,"docs":[
                  {
                    "displayterm":"Reproductive, Maternal, Newborn, Child and Adolescent Health"}]
              }},
            {
              "groupValue":"foundation",
              "doclist":{"numFound":1,"start":0,"docs":[
                  {
                    "displayterm":"The new century Medical and Educational foundation malegaon, Nashik"}]
              }}]}}}
    

    【讨论】:

      【解决方案2】:

      您是否按照here 的说明启用了 group.facet=true。您至少需要 3.3

      【讨论】:

      • group.facet 在 solrNet 0.4 中不可用。知道比修改 SolrNet 的源代码更好的解决方法吗?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-11-10
      • 2011-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多