【问题标题】:Solr faceting : compute "others" categorySolr faceting:计算“其他”类别
【发布时间】:2019-12-16 14:58:05
【问题描述】:

我的 SOLR 应用程序在“descendant_path”字段上具有分面功能。刻面的数量可能很大(例如 100),但我觉得它没有用。所以我最好有 X(例如 2)个方面和一个标记为“其他”的额外方面。

到目前为止我有:

 - 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 参数可以返回所有 facet.limit 内未返回的 facet counts 的总和?

例如,如果 Solr 返回 5 个带有 facet.limit = -1 的构面
一个 (34) 乙 (30) C (28) D (10) E (4)

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

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

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

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

任何帮助表示赞赏

【问题讨论】:

    标签: solr lucene facet


    【解决方案1】:

    没有内置属性 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

    【讨论】:

    • 感谢@christofr,您回答了有关此功能存在的问题!所以我会保留手动计算,没关系!
    • 使用num_found - sum(facet_counts)假设一个文档只能属于一个bucket,实际情况可能并非如此。如果您从 num_found 开始计算,请注意这一点。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-05
    • 1970-01-01
    • 2018-05-12
    相关资源
    最近更新 更多