Java Timestamp to ElasticSearch Java REST Client 6.6

I have sample value "1547674800000" which I formated to Java.sql.timestamp and tryng to insert into ELastic Search via Java REST Client.

Timestamp Value :1547674800000

I am getting error

Exception in thread "main" java.lang.IllegalArgumentException: cannot write xcontent for unknown value of type class java.sql.Timestamp
at org.elasticsearch.common.xcontent.XContentBuilder.unknownValue(XContentBuilder.java:833)
at org.elasticsearch.common.xcontent.XContentBuilder.map(XContentBuilder.java:888)
at org.elasticsearch.common.xcontent.XContentBuilder.map(XContentBuilder.java:870)
at org.elasticsearch.action.index.IndexRequest.source(IndexRequest.java:343)
at org.elasticsearch.action.index.IndexRequest.source(IndexRequest.java:332)
at com.JavaConsumer.insertDNSVolume(JavaConsumer.java:106)
at com.JavaConsumer.main(JavaConsumer.java:178)

hi,
could you please paste the code for your com.JavaConsumer.insertDNSVolume method?

Thanks

Hello,
I am aware that this is the REST client, but I'm having the same issue with the TransportClient and I suspect it could have the same root.

I am migrating our current client from 5.4.3 to 6.6.0. In my case I'm fetching data from the database and convert the timestamp values from the oracle.sql.TIMESTAMP class to java.sql.Timestamp - that's how the client's been working for versions 2.3.3 and 5.4.3 and it has been fine so far.

This is how I send the requests to ES:

BulkProcessor bulkProcessor;
[...]
for (Map<String, Object> document : documents) {
IndexRequest request = new IndexRequest(localIndexName, type, id);
[...]
request.source(document);
bulkProcessor.add(request);

And this is the stack trace:

java.lang.IllegalArgumentException: cannot write xcontent for unknown value of type class java.sql.Timestamp
at org.elasticsearch.common.xcontent.XContentBuilder.unknownValue(XContentBuilder.java:833)
at org.elasticsearch.common.xcontent.XContentBuilder.map(XContentBuilder.java:888)
at org.elasticsearch.common.xcontent.XContentBuilder.map(XContentBuilder.java:870)
at org.elasticsearch.action.index.IndexRequest.source(IndexRequest.java:343)
at org.elasticsearch.action.index.IndexRequest.source(IndexRequest.java:332)

Let me know if you need any additional information.

Thanks in advance for your help!
Michael.

Looks like the issue was reported:

Not clear whether this will be dealt with or not though. Should I just turn the timestamp into a string like it is suggested in that github thread, though? It doesn't feel the right way of doing it...

Regards,
Michael.