Class cast exception in Rest High Level Client

I have an index with one of the field type is double. Using Transport client, I am able to get data from api. When migrated to Rest High Level Client, I am getting below error.

    org.elasticsearch.ElasticsearchException: Elasticsearch exception [type=class_cast_exception, reason=java.lang.Long cannot be cast to java.lang.Double]
	at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:509) ~[elasticsearch-6.5.4.jar:6.5.4]
	at org.elasticsearch.ElasticsearchException.fromXContent(ElasticsearchException.java:420) ~[elasticsearch-6.5.4.jar:6.5.4]
	at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:450) ~[elasticsearch-6.5.4.jar:6.5.4]
	at org.elasticsearch.ElasticsearchException.failureFromXContent(ElasticsearchException.java:616) ~[elasticsearch-6.5.4.jar:6.5.4]
	at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:169) ~[elasticsearch-6.5.4.jar:6.5.4]
	at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:1793) ~[elasticsearch-rest-high-level-client-6.5.4.jar:6.5.4]
	at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:1769) ~[elasticsearch-rest-high-level-client-6.5.4.jar:6.5.4]
	at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1606) ~[elasticsearch-rest-high-level-client-6.5.4.jar:6.5.4]
	at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1563) ~[elasticsearch-rest-high-level-client-6.5.4.jar:6.5.4]
	at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1525) ~[elasticsearch-rest-high-level-client-6.5.4.jar:6.5.4]
	at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:990) ~[elasticsearch-rest-high-level-client-6.5.4.jar:6.5.4]

After modifying field type to Long, then api is working.

But I am able to retrieve for the same query from kibana without changing type. It means that the cast is not happening during fetch time with High Level Client.

Please let me know.

Hi,
that looks like a bug, could you recreate this and open an issue in the Elasticsearch repo please?

1 Like

Please share me link, i will create it

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