【问题标题】:SOLR - group by field and then get distinct value by another fieldSOLR - 按字段分组,然后通过另一个字段获得不同的值
【发布时间】:2019-01-14 11:56:38
【问题描述】:

我正在使用 apache solr 搜索记录。在我的情况下,我有一个包含列类别和子类别等的表格。

我想按类别分组,然后从分组结果中获取不同的子类别列表。这在 apache solr 中可行吗?

如果是,请帮我解决这个问题。 提前致谢。

【问题讨论】:

    标签: database search solr nosql


    【解决方案1】:

    您可以使用枢轴刻面做到这一点:

    facet=on&facet.pivot=category,subcategory
    

    这将为您提供每个类别的所有子类别的方面。

    您也可以使用Facet JSON API。该页面采用的示例:

    top_categories:{
      type: terms,
      field: category,
      limit: 5,
      facet:{
        top_subcategories:{
          type: terms, 
          field: subcategory,
          limit: 20
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2019-10-25
      • 1970-01-01
      • 2019-05-18
      • 1970-01-01
      • 1970-01-01
      • 2017-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多