I'm using below code to insert some documents in elasticsearch index. But
when inserting in the es the time is coming as UTC format rather than
original GMT+5:30Z format. Where as the Sysout before indexing is giving me
correct format as 2014-08-11T18:23:13.447+05:30 . Please let me know how
to keep the orizinal time format.
On Monday, August 11, 2014 7:51:00 PM UTC+5:30, Subhadip Bagui wrote:
Hi,
I'm using below code to insert some documents in elasticsearch index. But
when inserting in the es the time is coming as UTC format rather than
original GMT+5:30Z format. Where as the Sysout before indexing is giving me
correct format as 2014-08-11T18:23:13.447+05:30 . Please let me know
how to keep the orizinal time format.
XContentBuilder (I assume jsonBuilder() returns it) serialises date using UTC timezone by default.
If you’d like to use different format, you’d need to build your own DateTimeFormatter and pass it when you add date type field.
For example, to use ISO date time format with specified timezone:
org.elasticsearch.transport.TransportSerializationException: Failed to
deserialize exception response from stream
at
org.elasticsearch.transport.netty.MessageChannelHandler.handlerResponseError(MessageChannelHandler.java:169)
at
org.elasticsearch.transport.netty.MessageChannelHandler.messageReceived(MessageChannelHandler.java:123)
at
org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
at
org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
at
org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
at
org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:296)
Not sure what’s failing because of deserialize issue. It usually happens when you use different version of java.
You can see what the problem is by checking ES log instead too.
To check you are sending document in correct format, you may want to print JSON before sending index request:
org.elasticsearch.transport.TransportSerializationException: Failed to
deserialize exception response from stream
at
org.elasticsearch.transport.netty.MessageChannelHandler.handlerResponseError(MessageChannelHandler.java:169)
at
org.elasticsearch.transport.netty.MessageChannelHandler.messageReceived(MessageChannelHandler.java:123)
at
org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
at
org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
at
org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
at
org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:296)
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.