gpt4 book ai didi

elasticsearch - mysql到Elasticsearch:使用选定字段进行分组和排序

转载 作者:行者123 更新时间:2023-12-03 02:14:07 26 4
gpt4 key购买 nike

select count(*) as count, (timestamp div 10) as time from table group by time order by time;
如何转换为Elasticsearch或使用其他es函数来解决它。

最佳答案

尝试以下查询:

GET <indexName>/_search
{
"size": 0,
"aggs": {
"RESULTS": {
"terms": {
"script": {
"source": "doc['timestamp'].value.getMillis()/10"
},
"order": {
"_term": "desc"
}
}
}
}
}

关于elasticsearch - mysql到Elasticsearch:使用选定字段进行分组和排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63953225/

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