# Why Elasticsearch doesn't serialize LocalDate?

**URL:** <https://discuss.elastic.co/t/why-elasticsearch-doesnt-serialize-localdate/179714>\
**Category:** Elasticsearch\
**Created:** [May 6, 2019, 7:06am UTC](https://discuss.elastic.co/t/why-elasticsearch-doesnt-serialize-localdate/179714 "2019-05-06T07:06:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tworogue](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tworogue/32/45591_2.png) [@tworogue](https://discuss.elastic.co/u/tworogue)\
**Post date:** [May 6, 2019, 7:06am UTC](https://discuss.elastic.co/t/why-elasticsearch-doesnt-serialize-localdate/179714/1 "2019-05-06T07:06:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 6, 2019, 7:24am UTC](https://discuss.elastic.co/t/why-elasticsearch-doesnt-serialize-localdate/179714/2 "2019-05-06T07:24:20Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 3, 2019, 7:24am UTC](https://discuss.elastic.co/t/why-elasticsearch-doesnt-serialize-localdate/179714/3 "2019-06-03T07:24:39Z")

</div>

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