DateHistogramAggregationBuilder dateHistogramAggregationBuilder = AggregationBuilders
.dateHistogram(AggValueEnum.TIME_INTERVAL.getAggName()).field(AggValueEnum.TIME_INTERVAL.getField()).minDocCount(0).extendedBounds(longBounds);
dateHistogramAggregationBuilder.fixedInterval(timeIntervalAggRequest.getDimension());
dateHistogramAggregationBuilder.offset("7d");
The final HTTP request sent was
"aggregations": {
"time_interval": {
"date_histogram": {
"field": "ddtime",
"fixed_interval": "7d",
"offset": 604800000,
"order": {
"_key": "asc"
},
"keyed": false,
"min_doc_count": 0,
"extended_bounds": {
"min": 1761696000021,
"max": 1769472000000
}
},
......
offset is parsed as a long type.
"offset": 604800000,
But ES expects a string. ("offset": "6d",)
"aggregations": {
"time_interval": {
"date_histogram": {
"field": "ddtime",
"fixed_interval": "7d",
"offset": "6d",
"order": {
"_key": "asc"
},
"keyed": false,
"min_doc_count": 0,
"extended_bounds": {
"min": 1761696000021,
"max": 1769472000000
}
},
client code:
public static long parseStringOffset(String offset) {
if (offset.charAt(0) == '-') {
return -TimeValue.parseTimeValue(
offset.substring(1),
null,
DateHistogramAggregationBuilder.class.getSimpleName() + ".parseOffset"
).millis();
}
int beginIndex = offset.charAt(0) == '+' ? 1 : 0;
return TimeValue.parseTimeValue(
offset.substring(beginIndex),
null,
DateHistogramAggregationBuilder.class.getSimpleName() + ".parseOffset"
).millis();
}
Is this a bug, how can I solve it?