情境:
我有以下(简化的)数据库表情境:
ID ProductName ProductCategory Colour Price
----------------------------------------------------------
1 BatmanTShirt T-Shirt Black 22
2 BatmanTShirt T-Shirt Blue 20
3 SupermanTShirt T-Shirt Blue 19
4 SpidermanTrousers Trousers Red 28
5 SpidermanTrousers Trousers Black 30
我的愿望:
在SOLR索引中,我希望将这些数据以规范化的方式映射,这样只会创建3个SOLR文档(如下所示),而不是5个。
<doc1>
<ID>1</ID>
<ProductName>BatmanTShirt</ProductName>
<ProductCategory>T-Shirt</ProductCategory>
<OtherDetails>{ {1, Black, 22}, {2, Blue, 20} }</OtherDetails>
</doc1>
<doc2>
<ID>3</ID>
<ProductName>SupermanTShirt</ProductName>
<ProductCategory>T-Shirt</ProductCategory>
<OtherDetails>{ {3, Blue, 19} }</OtherDetails>
</doc2>
<doc3>
<ID>4</ID>
<ProductName>SpidermanTrousers</ProductName>
<ProductCategory>Trousers</ProductCategory>
<OtherDetails>{ {4, Red, 28}, {5, black, 30} }</OtherDetails>
</doc3>
一些说明:
<ID>
将包含该组中的最小ID。<OtherDetails>
将包含独特的ID以及在分组时被省略的其他细节。这将是一个多值字段,数据类型为列表,其中还有另一个细节列表 {ID、颜色、价格}。
问题:
有人知道这是如何实现的吗?
P.S.
进行这种“分组”操作的原因是我想在产品类别上进行聚合。如果我在产品类别上使用聚合,当前生成的计数将是:
T-Shirt (3)
Trousers (2)
现在我想根据产品类别进行分面,但不包括颜色和价格数据,这样我就只想要两件 T 恤(一件是 Batman 的,一件是 Superman 的)和一条裤子(Spiderman 的)。因此,我想展示的是这个:
T-Shirt (2)
Trousers (1)
我做了一些研究,发现这个功能(称为帖子组分面或矩阵计数)目前正在进行中,如此SOLR补丁中所述。因此,我需要一个暂时的解决方法,因为这可能需要一段时间才能完成。