Date_time_exception: Field Year cannot be printed as the value -292275055 exceeds the maximum print width of 4]

I got date_time_exception after disabling dynamic mapping and adding mapping for a Date attribute like this:

"mappings": {
    "dynamic": false,
  ........


  "updateDate": {
                "type": "date",
                "format": "date_hour_minute_second_millis",
                "null_value": ""
              },
....
}

then I got exception:

Caused by: NotSerializableExceptionWrapper[: Field Year cannot be printed as the value -292275055 exceeds the maximum print width of 4]; nested: NotSerializableExceptionWrapper[date_time_exception: Field Year cannot be printed as the value -292275055 exceeds the maximum print width of 4];
    at org.elasticsearch.ElasticsearchException.guessRootCauses(ElasticsearchException.java:639)
    at org.elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:398)
    ... 44 more
Caused by: NotSerializableExceptionWrapper[date_time_exception: Field Year cannot be printed as the value -292275055 exceeds the maximum print width of 4]
    at java.time.format.DateTimeFormatterBuilder$NumberPrinterParser.format(DateTimeFormatterBuilder.java:2916)
    at java.time.format.DateTimeFormatterBuilder$CompositePrinterParser.format(DateTimeFormatterBuilder.java:2525)
    at java.time.format.DateTimeFormatterBuilder$CompositePrinterParser.format(DateTimeFormatterBuilder.java:2525)
    at java.time.format.DateTimeFormatter.formatTo(DateTimeFormatter.java:1903)
    at java.time.format.DateTimeFormatter.format(DateTimeFormatter.java:1877)
    at org.elasticsearch.common.time.JavaDateFormatter.format(JavaDateFormatter.java:284)
    at org.elasticsearch.search.DocValueFormat$DateTime.format(DocValueFormat.java:303)
    at org.elasticsearch.search.DocValueFormat$DateTime.format(DocValueFormat.java:216)
    at org.elasticsearch.search.SearchSortValuesAndFormats.<init>(SearchSortValuesAndFormats.java:35)
    at org.elasticsearch.action.search.BottomSortValuesCollector.consumeTopDocs(BottomSortValuesCollector.java:65)
    at org.elasticsearch.action.search.SearchQueryThenFetchAsyncAction.onShardResult(SearchQueryThenFetchAsyncAction.java:130)
    at org.elasticsearch.action.search.AbstractSearchAsyncAction$1.innerOnResponse(AbstractSearchAsyncAction.java:320)
    ... 40 more

are there anyone get such problem before or know what the problem is? Thanks

Welcome to our community! :smiley:

Are you adding this mapping to a new index? Or are you trying to update an existing mapping?
If you are adding this to a new one, are you getting this when you add data in? Can you share the data?

Also lease format your code/logs/config using the </> button, or markdown style back ticks. It helps to make things easy to read which helps us help you :slight_smile:

Thanks for your reply, Mark. This is an exiting index. We didn't claim 'dynamic=false' before and we used following mapping for a 'date' field, everything worked fine.

"updateDate": {
"type": "date",
"format": "date_hour_minute_second_millis",
"null_value": ""
},

We recently explicitly claim 'dynamic=false' and the mapping for 'updateDate' still the same, but got exception:

Caused by: NotSerializableExceptionWrapper[: Field Year cannot be printed as the value -292275055 exceeds the maximum print width of 4]

This error happened when we use sorting by 'updateDate' in a query. I can't share the data as I don't even know which doc has the 'bad' year and hundred of thousands docs were involved in the query. But for sure, we didn't get error before we explicitly claimed 'dynamic=false'.