Why Elasticsearch doesn't serialize LocalDate?

Hello,

I'd like to pass my LocalDate as parameter to methods in QueryBuilder. For example, to QueryBuilders#matchQuery.

But if I do so, I face following exception:

    09:52:59.757 [pool-4-thread-1] ERROR o.n.i.g.search.GenericSearcherImpl - Exception occurred while performing the search.
org.elasticsearch.common.util.concurrent.UncategorizedExecutionException: Failed execution
	at org.elasticsearch.action.support.AdapterActionFuture.rethrowExecutionException(AdapterActionFuture.java:86)
	at org.elasticsearch.action.support.AdapterActionFuture.actionGet(AdapterActionFuture.java:44)
	at com.example.elasticsearch.common.BaseElasticConnection.search(BaseElasticConnection.java:439)
	at org.example.generic.search.GenericSearcherImpl._runElasticSearch(GenericSearcherImpl.java:303)
	at org.example.generic.search.GenericSearcherImpl._runSearch(GenericSearcherImpl.java:247)
	at org.example.generic.search.GenericSearcherImpl.access$000(GenericSearcherImpl.java:34)
	at org.example.generic.search.GenericSearcherImpl$2.run(GenericSearcherImpl.java:182)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: can not write type [class java.time.LocalDate]
	at org.elasticsearch.common.io.stream.StreamOutput.writeGenericValue(StreamOutput.java:664)
	at org.elasticsearch.index.query.BaseTermQueryBuilder.doWriteTo(BaseTermQueryBuilder.java:134)
	at org.elasticsearch.index.query.AbstractQueryBuilder.writeTo(AbstractQueryBuilder.java:73)
	at org.elasticsearch.common.io.stream.StreamOutput.writeNamedWriteable(StreamOutput.java:883)
	at org.elasticsearch.index.query.AbstractQueryBuilder.writeQueries(AbstractQueryBuilder.java:249)
	at org.elasticsearch.index.query.BoolQueryBuilder.doWriteTo(BoolQueryBuilder.java:104)
	at org.elasticsearch.index.query.AbstractQueryBuilder.writeTo(AbstractQueryBuilder.java:73)
	at org.elasticsearch.common.io.stream.StreamOutput.writeNamedWriteable(StreamOutput.java:883)
	at org.elasticsearch.common.io.stream.StreamOutput.writeOptionalNamedWriteable(StreamOutput.java:894)
	at org.elasticsearch.search.builder.SearchSourceBuilder.writeTo(SearchSourceBuilder.java:252)
	at org.elasticsearch.common.io.stream.StreamOutput.writeOptionalWriteable(StreamOutput.java:758)
	at org.elasticsearch.action.search.SearchRequest.writeTo(SearchRequest.java:443)
	at org.elasticsearch.transport.TcpTransport.buildMessage(TcpTransport.java:1236)
	at org.elasticsearch.transport.TcpTransport.sendRequestToChannel(TcpTransport.java:1108)
	at org.elasticsearch.transport.TcpTransport.access$1700(TcpTransport.java:122)
	at org.elasticsearch.transport.TcpTransport$NodeChannels.sendRequest(TcpTransport.java:482)
	at org.elasticsearch.transport.TransportService.sendRequestInternal(TransportService.java:598)
	at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:518)
	at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:506)
	at org.elasticsearch.action.TransportActionNodeProxy.execute(TransportActionNodeProxy.java:51)
	at org.elasticsearch.client.transport.TransportProxyClient.lambda$execute$0(TransportProxyClient.java:60)
	at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:250)
	at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:60)
	at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:371)
	at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:405)
	at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:394)
	at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:46)
	... 10 common frames omitted

Therefore, I need to transform my LocalDate to String (in ISO format).
Please, explain me the reason ES doesn't serialize LocalDate properly.
Why was it decided not to implement it?

Hey.

First of all, you should use the RestClient instead of the TransportClient which will be removed in the next major version.

Could you share the code you are using?

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