0

I am pushing a json file from Kafka to Elasticsearch and then visualize the data in Kibana.

Here is my json file format:

[{
"A": "---",
"B": "---",
"C": "---",
"D": "---",
"ABC": "---",
"CDE": "---",
"FGY": "1110",
"ADF": "226",
"SSS": "nil",
"ASA": "9.5",
"DFGHJKLIWSSFFFSF": "12121",
"sasfasfafasfsa": "0.21212",
"TEST": "12121121",
"AGAIN_TEST": "1.23456",
"SSS": "---",
"ASD": "---",
"ASSDFFF": "---",
"QQQQ": "61.2793",
"UYTR": "3619",
"testing": "58.3649",
"fffff": "1010",
"Fasa_sasfaf": "9.000"
}, {
"A": "1616161",
"B": "0.234",
"C": "---",
"D": "---",
"ABC": "1.11",
"CDE": "---",
"FGY": "323",
"ADF": "121",
"SSS": "---",
"ASA": "9.5",
"DFGHJKLIWSSFFFSF": "12121",
"sasfasfafasfsa": "0.21212",
"TEST": "---",
"AGAIN_TEST": "1.23456",
"SSS": "---",
"ASD": "121212",
"ASSDFFF": "---",
"QQQQ": "61.2793",
"UYTR": "3619",
"testing": "50.3649",
"fffff": "1030",
"Fasa_sasfaf": "123.012"
}]

As per the website http://jsonlint.com/, the json file I am using is correct. But on passing that file in Kafka, I am getting an error in elasticsearch as

Can not instantiate value of type [map type; class java.util.LinkedHashMap, [simple type, class java.lang.String] -> [simple type, class java.lang.Object]] from JSON String; no single-String constructor/factory method

Here is the complete stack trace:

Can not instantiate value of type [map type; class java.util.LinkedHashMap, [simple type, class java.lang.String] -> [simple type, class java.lang.Object]] from JSON String; no single-String constructor/factory method
at org.codehaus.jackson.map.deser.std.StdValueInstantiator._createFromStringFallbacks(StdValueInstantiator.java:379)
at org.codehaus.jackson.map.deser.std.StdValueInstantiator.createFromString(StdValueInstantiator.java:268)
at org.codehaus.jackson.map.deser.std.MapDeserializer.deserialize(MapDeserializer.java:244)
at org.codehaus.jackson.map.deser.std.MapDeserializer.deserialize(MapDeserializer.java:33)
at org.codehaus.jackson.map.ObjectReader._bindAndClose(ObjectReader.java:768)
at org.codehaus.jackson.map.ObjectReader.readValue(ObjectReader.java:473)
at org.elasticsearch.river.kafka.IndexDocumentProducer.addMessagesToBulkProcessor(IndexDocumentProducer.java:71)
at org.elasticsearch.river.kafka.KafkaWorker.consumeMessagesAndAddToBulkProcessor(KafkaWorker.java:107)
at org.elasticsearch.river.kafka.KafkaWorker.run(KafkaWorker.java:78)
at java.lang.Thread.run(Thread.java:745)
Sweet
  • 187
  • 3
  • 15
  • I think it's an instantiation issue. Paste the complete error stack trace... – harshavmb Dec 26 '15 at 07:44
  • Updated the question with the stack trace. Thanks. – Sweet Dec 26 '15 at 07:56
  • 1
    These links might help you. [http://stackoverflow.com/questions/10839297/jsonmappingexception-can-not-instantiate-value-of-type-simple-type-a-b-c-comp] and [http://stackoverflow.com/questions/21173054/simple-json-structure-throwing-error-when-converting-to-pojo] – harshavmb Dec 26 '15 at 08:10
  • The document you show above is actually a JSON array. Are you willing to store each element of that array as a different document or is that array supposed to be store as a single document? – Val Dec 27 '15 at 04:51
  • I want to know if I can pass that doc as an array in Kafka and still be able to see it in elasticsearch? – Sweet Dec 27 '15 at 23:30

0 Answers0