# HighLevelRestClient7.17.5 date\_histogram offset is unexpected

**URL:** <https://discuss.elastic.co/t/highlevelrestclient7-17-5-date-histogram-offset-is-unexpected/383208>\
**Category:** Elasticsearch\
**Created:** [November 4, 2025, 12:35pm UTC](https://discuss.elastic.co/t/highlevelrestclient7-17-5-date-histogram-offset-is-unexpected/383208 "2025-11-04T12:35:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZLEternity](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zleternity/32/111443_2.png) [@ZLEternity](https://discuss.elastic.co/u/ZLEternity)\
**Post date:** [November 4, 2025, 12:35pm UTC](https://discuss.elastic.co/t/highlevelrestclient7-17-5-date-histogram-offset-is-unexpected/383208/1 "2025-11-04T12:35:57Z")

</div>

```auto
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

```auto
"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.

```auto
"offset": 604800000,

```

But ES expects a string. ("offset": "6d",)

```auto
"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:

```auto
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?
