确定solr中的facet字段的术语

时间:2018-05-15 07:32:05

标签: solr facet faceted-search solar

我基于facet.field,我有一个情况。在我的商店里,我有基础产品和变体,当我使用facet.field时,我会得到基础产品和变体的数量:

Category:
   Chairs(30) <- this is count of base products and variants
   Tables(20) <- this is count of base products and variants

我想为facet.field添加一些术语,以便仅对变体进行返回计数,每个产品都有&#34; productType&#34;:&#34; baseProduct&#34;或&#34; productType&#34;:&#34; variantProduct&#34; 我想使用这些字段。

有什么想法吗?如何在某些查询中使用此功能,请帮助

1 个答案:

答案 0 :(得分:0)

您可以use facet.pivot为每种类型获取不同的计数:

&facet.pivot=productType,category

你也可以use the JSON Facet API做两个不同的方面:

{
  base: {
     type: terms,
     field: category,
     domain: { filter: "productType:baseProduct" }
  },
  variant: {
     type: terms,
     field: category,
     domain: { filter : "productType:variantProduct" }
   }
}