【发布时间】:2018-01-30 23:29:51
【问题描述】:
我正在寻找一种从已过滤的 2 级嵌套对象中获取最小值和最大值的方法。所以下面我试图获得具有currencyCode GBP 的最低和最高价格。每个产品可以有多个 sku,每个 sku 可以有多个价格(尽管只有 1 个是英镑):
"hits": [
{
"_index": "product",
"_type": "main",
"_id": "1",
"_score": 1,
"_source": {
"skus": [
{
"prices": [
{
"currencyCode": "GBP",
"price": 15
}
]
}
]
}
},{
"_index": "product",
"_type": "main",
"_id": "2",
"_score": 1,
"_source": {
"skus": [
{
"prices": [
{
"currencyCode": "GBP",
"price": 20
}
]
}
]
}
},
{
"_index": "product",
"_type": "main",
"_id": "3",
"_score": 1,
"_source": {
"skus": [
{
"prices": [
{
"currencyCode": "GBP",
"price": 25
}
]
}
]
}
}]
}
所以我想要最少 15 个,最多 25 个。我已经研究了 Filter Aggregation 和 Nested Aggregation,但找不到答案。
我使用的是 ElasticSearch 5.5 版。
在转换为 Nest .net 之前,我正在尝试先让查询正常工作。
任何帮助将不胜感激。
【问题讨论】:
标签: elasticsearch elasticsearch-5 elasticsearch-net