Elasticsearch 时尚商务
Elasticsearch on fashion commerce
我在 elasticsearch 中索引了以下数据集
[
{
"id": "1",
"name": "Red T-shirt",
"size": "S",
"styleId": "R-1"
},
{
"id": "2",
"name": "Red T-shirt",
"size": "M",
"styleId": "R-1"
},
{
"id": "3",
"name": "Red T-shirt",
"size": "L",
"styleId": "R-1"
},
{
"id": "4",
"name": "White T-shirt",
"size": "S",
"styleId": "W-1"
},
{
"id": "5",
"name": "White T-shirt",
"size": "XL",
"styleId": "W-1"
}
]
在搜索结果中,我希望产品按 styleId 分组。是否有可能像下面的样本结果?在亚马逊、Myntra、Flipkart 等大多数商业网站中,我看到他们正在做与我正在尝试的相同的事情。我尝试过许多弹性搜索概念,例如“崩溃”,但没有成功。使用 kibana 和 elasticsearch 7.4 版。任何建议将不胜感激。
[
{
"id": "1",
"name": "Red T-shirt",
"size": "S",
"styleId": "R-1",
"sizes": [
{
"id": "2",
"name": "Red T-shirt",
"size": "M",
"styleId": "R-1"
},
{
"id": "3",
"name": "Red T-shirt",
"size": "L",
"styleId": "R-1"
}
]
},
{
"id": "4",
"name": "White T-shirt",
"size": "S",
"styleId": "W-1",
"sizes": [
{
"id": "5",
"name": "White T-shirt",
"size": "XL",
"styleId": "W-1"
}
]
},
]
您可以将 collapse 与基数聚合结合使用。
Cardinality 将给出组级别计数
{
"_source": "false",
"collapse": {
"field": "styleId.keyword",
"inner_hits": {
"name": "group-details",
"size": 5
}
},
"from": 0,
"size": 5,
"aggs": {
"type_count": {
"cardinality": {
"field": "styleId.keyword"
}
}
}
}
我在 elasticsearch 中索引了以下数据集
[
{
"id": "1",
"name": "Red T-shirt",
"size": "S",
"styleId": "R-1"
},
{
"id": "2",
"name": "Red T-shirt",
"size": "M",
"styleId": "R-1"
},
{
"id": "3",
"name": "Red T-shirt",
"size": "L",
"styleId": "R-1"
},
{
"id": "4",
"name": "White T-shirt",
"size": "S",
"styleId": "W-1"
},
{
"id": "5",
"name": "White T-shirt",
"size": "XL",
"styleId": "W-1"
}
]
在搜索结果中,我希望产品按 styleId 分组。是否有可能像下面的样本结果?在亚马逊、Myntra、Flipkart 等大多数商业网站中,我看到他们正在做与我正在尝试的相同的事情。我尝试过许多弹性搜索概念,例如“崩溃”,但没有成功。使用 kibana 和 elasticsearch 7.4 版。任何建议将不胜感激。
[
{
"id": "1",
"name": "Red T-shirt",
"size": "S",
"styleId": "R-1",
"sizes": [
{
"id": "2",
"name": "Red T-shirt",
"size": "M",
"styleId": "R-1"
},
{
"id": "3",
"name": "Red T-shirt",
"size": "L",
"styleId": "R-1"
}
]
},
{
"id": "4",
"name": "White T-shirt",
"size": "S",
"styleId": "W-1",
"sizes": [
{
"id": "5",
"name": "White T-shirt",
"size": "XL",
"styleId": "W-1"
}
]
},
]
您可以将 collapse 与基数聚合结合使用。 Cardinality 将给出组级别计数
{
"_source": "false",
"collapse": {
"field": "styleId.keyword",
"inner_hits": {
"name": "group-details",
"size": 5
}
},
"from": 0,
"size": 5,
"aggs": {
"type_count": {
"cardinality": {
"field": "styleId.keyword"
}
}
}
}