fix : add offset to es date_histogam (#2757)

This commit is contained in:
smx_Morgan 2025-06-25 17:37:51 +10:00 committed by GitHub
parent 514913a97a
commit bc6ff7f4ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -416,7 +416,9 @@ func QueryData(ctx context.Context, queryParam interface{}, cliTimeout int64, ve
MinDocCount(1)
if strings.HasPrefix(version, "7") {
tsAggr.FixedInterval(fmt.Sprintf("%ds", param.Interval))
// 添加偏移量使第一个分桶bucket的左边界对齐为 start 时间
offset := (start % param.Interval) - param.Interval
tsAggr.FixedInterval(fmt.Sprintf("%ds", param.Interval)).Offset(fmt.Sprintf("%ds", offset))
} else {
// 兼容 7.0 以下的版本
// OpenSearch 也使用这个字段