Sending data to elastic search via Rest client from a java application it it is complaining about the date format below is the stack trace that it being spit out.
1. ElasticsearchStatusException[Elasticsearch exception [type=mapper_parsing_exception, reason=failed to parse field [start_time] of type [long] in document with id 'test_metric']]; nested: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=For input string: "2020-07-20T23:36:16.000Z"]];
2. at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:177)
3. at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:2053)
4. at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:2030)
5. at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1777)
6. at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1734)
7. at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1696)
8. at org.elasticsearch.client.RestHighLevelClient.index(RestHighLevelClient.java:928)
9. at com.bah.cdssf.common.metric.filter.SampleMetricElasticClient.create(SampleMetricElasticClient.java:69)
10. at com.bah.cdssf.common.metric.filter.SampleMetricElasticClientTest.testCreate(SampleMetricElasticClientTest.java:54)
11. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
12. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
13. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
14. at java.lang.reflect.Method.invoke(Method.java:498)
15. at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
16. at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
17. at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
18. at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
19. at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
20. at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
21. at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
22. at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
23. at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
24. at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
25. at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
26. at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
27. at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
28. at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
29. at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
30. at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
31. at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
32. at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
33. at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
34. Suppressed: org.elasticsearch.client.ResponseException: method [PUT], host [http://x.x.x.x:9200], URI [/metricbeat/doc/test_metric?timeout=1m], status line [HTTP/1.1 400 Bad Request]
35. {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse field [start_time] of type [long] in document with id 'test_metric'"}],"type":"mapper_parsing_exception","reason":"failed to parse field [start_time] of type [long] in document with id 'test_metric'","caused_by":{"type":"illegal_argument_exception","reason":"For input string: \"2020-07-20T23:36:16.000Z\""}},"status":400}
36. at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClient.java:936)
37. at org.elasticsearch.client.RestClient.performRequest(RestClient.java:233)
38. at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1764)
39. ... 28 more
40. Caused by: org.elasticsearch.client.ResponseException: method [PUT], host [http://x.x.x.x:9200], URI [/metricbeat/doc/test_metric?timeout=1m], status line [HTTP/1.1 400 Bad Request]
41. {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse field [start_time] of type [long] in document with id 'test_metric'"}],"type":"mapper_parsing_exception","reason":"failed to parse field [start_time] of type [long] in document with id 'test_metric'","caused_by":{"type":"illegal_argument_exception","reason":"For input string: \"2020-07-20T23:36:16.000Z\""}},"status":400}
42. at org.elasticsearch.client.RestClient$1.completed(RestClient.java:552)
43. at org.elasticsearch.client.RestClient$1.completed(RestClient.java:537)
44. at org.apache.http.concurrent.BasicFuture.completed(BasicFuture.java:119)
45. at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.responseCompleted(DefaultClientExchangeHandlerImpl.java:177)
46. at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.processResponse(HttpAsyncRequestExecutor.java:436)
47. at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.inputReady(HttpAsyncRequestExecutor.java:326)
48. at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:265)
49. at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:81)
50. at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:39)
51. at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:114)
52. at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:162)
53. at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:337)
54. at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315)
55. at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276)
56. at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
57. at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:588)
58. at java.lang.Thread.run(Thread.java:748)
59. Caused by: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=For input string: "2020-07-20T23:36:16.000Z"]]
60. at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:509)
61. at org.elasticsearch.ElasticsearchException.fromXContent(ElasticsearchException.java:420)
62. at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:450)
63. at org.elasticsearch.ElasticsearchException.failureFromXContent(ElasticsearchException.java:616)
64. at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:169)
65. ... 31 more
In my code i am using java.util.Date
class and using the simpleDateFormat
to parse the Date.toString()
output, and the format of the date looks similar to what i see in already indexed date values 2020-07-20T23:36:16.000Z
so not sure what the issue is here, any ideas?