【发布时间】:2015-09-06 01:35:13
【问题描述】:
基本上,我在这里尝试做的是从分层存储的字符串中获取第二级下的类别。问题是层次结构的级别各不相同,一个产品类别可能有六个级别,而另一个只有四个级别,否则我只会实现预定义的级别。
我有一些产品的类别如下:
[
{
title: 'product one',
categories: [
'clothing/mens/shoes/boots/steel-toe'
]
},
{
title: 'product two',
categories: [
'clothing/womens/tops/sweaters/open-neck'
]
},
{
title: 'product three',
categories: [
'clothing/kids/shoes/sneakers/light-up'
]
},
{
title: 'product etc.',
categories: [
'clothing/baby/bibs/super-hero'
]
},
... more products
]
我正在尝试像这样获得聚合桶:
buckets: [
{
key: 'clothing/mens',
...
},
{
key: 'clothing/womens',
...
},
{
key: 'clothing/kids',
...
},
{
key: 'clothing/baby',
...
},
]
我尝试查看过滤器前缀、包含和排除项,但我找不到任何有效的方法。请有人指出我正确的方向。
【问题讨论】:
标签: node.js elasticsearch aggregation