TimeValue - number_format_exception - Java client

I have a search request using PointInTimeBuilder:

PointInTimeBuilder pointInTimeBuilder = new PointInTimeBuilder("id...");
pointInTimeBuilder.setKeepAlive(TimeValue.timeValueSeconds(66));

The keep_alive value is 66 seconds. For some reason, ES java client converts it to:
"pit":{"id":"id...","keep_alive":"1.1m"}

keep_alive is converted to minutes. As a result, the following exception is thrown:

Caused by: org.elasticsearch.ElasticsearchException: Elasticsearch exception [type=illegal_argument_exception, reason=failed to parse [1.1m], fractional time values are not supported]
at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:485)
at org.elasticsearch.ElasticsearchException.fromXContent(ElasticsearchException.java:396)
at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:426)
... 67 common frames omitted
Caused by: org.elasticsearch.ElasticsearchException: Elasticsearch exception [type=number_format_exception, reason=For input string: "1.1"]

Is this the expected behavior and why?

That looks like a bug due to parsing of the TimeValue object. As a workaround for now, you should use full minutes as the proper argument to keep alive. Something like 1m or 2m.

I will file an issue in the Elasticsearch repo about this.

Update: I opened PointInTimeBuilder does not support all time values in keep alive timeout · Issue #75446 · elastic/elasticsearch · GitHub

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.