订单弹性搜索聚合
Order elasticsearch aggregation
我的 "query" 中有多个聚合,请参阅示例。有时我会使用更多聚合。我喜欢对聚合本身进行排序,因此 "brand" 始终位于聚合列表的顶部(在结果中)然后 "energy" 例如?
如果我自己尝试解决但找不到任何有用的方法。
{
"size": 1000,
"_source": ["id"],
"query": {
"bool": {
"must": [
{ "match": { "category_default": "2" }}
],
"must_not": [
{ "match": { "category_default": "2196" }},
{ "match": { "leverbaarheid_id": "3" }}
]
}
},
"aggs": {
"brand": {
"terms": {
"field": "brand.keyword",
"order": { "_term": "asc" }
}
},
"min_price": { "min": { "field" : "selling_price" } },
"max_price": { "max": { "field" : "selling_price" } },
"energy": {
"terms": {
"field": "energy.keyword",
"order": { "_term": "asc" }
}
}
}
}
我不认为这是直接可能的。
I like to order the aggregations itself so "brand" is always on top of the aggregations list (in the result) and then "energy" for example?
这里使用name it "aggregations list"虽然它实际上是一个JSON对象,也就是Elasticsearch aggregations:
的输出格式
Each aggregation is associated with a logical name that the user
defines ... . These logical names will also be used to uniquely
identify the aggregations in the response.
此外,在 JSON 对象中,键可以按任何顺序排列,例如参见 [=13=]。
您必须根据您的聚合创建一个列表,并在客户端正确排序。
我的 "query" 中有多个聚合,请参阅示例。有时我会使用更多聚合。我喜欢对聚合本身进行排序,因此 "brand" 始终位于聚合列表的顶部(在结果中)然后 "energy" 例如?
如果我自己尝试解决但找不到任何有用的方法。
{
"size": 1000,
"_source": ["id"],
"query": {
"bool": {
"must": [
{ "match": { "category_default": "2" }}
],
"must_not": [
{ "match": { "category_default": "2196" }},
{ "match": { "leverbaarheid_id": "3" }}
]
}
},
"aggs": {
"brand": {
"terms": {
"field": "brand.keyword",
"order": { "_term": "asc" }
}
},
"min_price": { "min": { "field" : "selling_price" } },
"max_price": { "max": { "field" : "selling_price" } },
"energy": {
"terms": {
"field": "energy.keyword",
"order": { "_term": "asc" }
}
}
}
}
我不认为这是直接可能的。
I like to order the aggregations itself so "brand" is always on top of the aggregations list (in the result) and then "energy" for example?
这里使用name it "aggregations list"虽然它实际上是一个JSON对象,也就是Elasticsearch aggregations:
的输出格式Each aggregation is associated with a logical name that the user defines ... . These logical names will also be used to uniquely identify the aggregations in the response.
此外,在 JSON 对象中,键可以按任何顺序排列,例如参见 [=13=]。
您必须根据您的聚合创建一个列表,并在客户端正确排序。