Solr 分面:计算 "others" 类别

Solr faceting : compute "others" category

我的 SOLR 应用程序在 "descendant_path" 字段上具有分面功能。 facet 的数量可能很大(例如 100),但我发现它没有用。所以我最好有 X(例如 2)个面和一个标有 "others".

的额外面

到目前为止我有:

 - set an unlimited number of facets (with facet.limit = -1), 
 - sorted them in decreasing count (with facet.sort = count), 
 - taken the first X (eg 2) elements
 - added the counts of the next elements together to form the "others" count

因为我找不到可以做到这一点的 Solr 分面参数。

因此不是重新发明轮子,我需要知道是否已经有一个 Solr 参数可以 return [=] 中所有未 returned 的面数的总和38=] ?

例如,如果 Solr returns 5 facet with facet.limit = -1
一个 (34) 乙 (30) 丙 (28) 丁 (10) E (4)

如果我现在设置 facet.limit = 2 它将 return 一个 (34) 乙 (30)

是否有一个参数 return 未包括的方面的所有计数的总和(即 C、D 和 E 的总计数)=> 其他 (42)?

请注意:facet.missing 没有做到这一点,因为它处理的是缺少类别的文档,而不是缺少方面的文档。

是否真的没有参数可以实现我的目标,或者我只是错过了它?

感谢任何帮助

没有内置的属性other给你这个计算。

不过很容易计算,用公式:

(numFound - sum(facet_counts)) - missing

在以下结果集中:

{ 
   "responseHeader":{ 
      "zkConnected":true,
      "status":0,
      "QTime":39,
      "params":{ 
         "q":"post_content:term",
         "facet.field":"my_terms",
         "facet.missing":"true",
         "fq":"date:[2018-12-11T00:00:00Z TO 2019-12-10T23:59:59Z]",
         "facet.mincount":"3",
         "rows":"0",
         "facet":"true",
         "wt":"json"
      }
   },
   "response":{ 
      "numFound":3883,
      "start":0,
      "maxScore":10.545702,
      "docs":[ ..
      ]
   },
   "facet_counts":{ 
      "facet_fields":{ 
         "my_terms":{ 
            "someterm":59,
            "anotherterm":43,
            "yetanotherterm":55,
            "":323
         }
      },
   }
}

所以我们有:

(3883 - (59 + 43 + 55)) - 323 = 3403

其他=3403