gpt4 book ai didi

elasticsearch group by based on every n rows(基于每n行的ElasticSearch分组)

转载 作者:bug小助手 更新时间:2023-10-25 22:11:15 26 4
gpt4 key购买 nike



I have a question in elasticsearch

我在ElasticSearch中有一个问题


I'm using single node elasticsearch 7.17.7

我使用的是单节点ElasticSearch 7.17.7


I have a table like this

我有一张这样的桌子


























































name age score
Benjamin 15 44
William 17 60
Jo 22 85
Sophia 13 86
Bob 16 90
Smith 19 93
Luck 17 95
John 15 98
Henry 25 99


My Question

我的问题


I want to sort by score field then average every 3 rows on field age

我想按分数字段排序,然后在字段年龄上平均每3行


I want this result

我想要这个结果




















age
(15+17+22)/3 = 18
(13+16+19)/3 = 16
(17+15+25)/3 = 19


Please help me solve this problem!

请帮我解决这个问题!


更多回答

This is not really possible to do inside elasticsearch. You can sort by score but you and even calculate rolling average, but you would have to group yourself. Which problem are you trying to solve? Would grouping by age ranges help you here?

这在ElasticSearch中是不可能做到的。你可以按分数排序,但你甚至可以计算滚动平均值,但你必须对自己进行分组。你想解决的是什么问题?在这方面,按年龄范围分组会对您有帮助吗?

thanks for answer - but its not about range . just about grouping every n sequence rows . I can't use range . I want to implement sql row_number in elastic then with using histogram maybe solve.

谢谢你的回答--但这不是射程的问题。只是对每n个序列行进行分组。我不能用射程。我想在弹性中实现SQL ROW_NUMBER,然后用直方图可能解决。

优秀答案推荐
更多回答

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com