gpt4 book ai didi

sql - Elasticsearch 查询过滤器

转载 作者:行者123 更新时间:2023-12-02 23:31:02 25 4
gpt4 key购买 nike

我是 flex 搜索的新手。

如何将以下SQL语句转换为 flex 搜索查询?

select sum(totaldevicecount),datasource from
(select distinct oskey,custkey,productkey,
timekey,totaldevicecount,datasource from es_reporting_data_new)
group by datasource;

谢谢

最佳答案

将查询简化到下面
select sum(totaldevicecount),datasource from es_reporting_data_new group by datasource;

ES查询将是

{
"aggs": {
"data_source": {
"terms": {
"field": "datasource"
},
"aggs": {
"total_device_count": {
"sum": {
"field": "totaldevicecount"
}
}
}
}
}
}

有关更多详细信息,请参见 Elastic Search Sum aggregation with group by and where condition

关于sql - Elasticsearch 查询过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36430648/

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