I指數這2個文件:Elasticsearch排序方面通過管道bucket_script聚集
POST my_index/my_type/1
{
"name": "Nephi",
"x": 5
}
POST my_index/my_type/2
{
"name": "Lehi",
"x": 10
}
這裏是我的搜索請求:
POST my_index/my_type/_search?size=0
{
"aggs": {
"some_terms_agg": {
"terms": {
"field": "name",
"order": {
"the_script_bucket": "asc"
}
},
"aggs": {
"the_sum": {
"sum": {
"field": "x"
}
},
"the_avg": {
"avg": {
"field": "x"
}
},
"the_script_bucket": {
"bucket_script": {
"buckets_path": {
"a": "the_sum.value",
"b": "the_avg.value"
},
"script": "a + b"
}
}
}
}
}
}
我得到這樣的錯誤:
無效term-aggregator訂單路徑[the_script_bucket]。未知聚集[the_script_bucket]
但是當我改變the_script_bucket
到另一個聚集像the_sum
或the_avg
它工作正常。我確信這是因爲the_script_bucket
是一個流水線聚合,但我想根據the_script_bucket
對條款進行排序,因此我可以(例如)查看100,000個文檔的前10個值。那可能嗎?