Unable to parse data while doing post to elastisearch


(Agwani) #1

I have have below request which runs fine on Kibana

PUT /test_sample/user_log/3
{
          "coulmn1": "TEST",
          "coulmn2": """{"coulmn21":{"sessionId":"1234567","caseId":"XYZ","actionId":"myPage"}}""",
          "type": "user_log",
          "created_datetime": "2017-02-15T03:03:47.000Z"
  }

But when I try to add data using rest api, I get exception

[2017-04-28T12:53:53,611][DEBUG][o.e.a.b.TransportShardBulkAction] [test_node] [test_sample][3] failed to execute bulk item (index) BulkShardRequest [[test_sample][3]] containing [index {[test_sample][user_log][1493398433411], source[{"coulmn1": "TEST","coulmn2": """{"coulmn21":{"sessionId":"1234567","caseId":"XYZ","actionId":"myPage"}}""","type": "user_log","created_datetime": "2017-02-15T03:03:47.000Z"}]}]
org.elasticsearch.index.mapper.MapperParsingException: failed to parse
        at org.elasticsearch.index.mapper.DocumentParser.wrapInMapperParsingException(DocumentParser.java:176) ~[elasticsearch-5.3.0.jar:5.3.0]
        at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:613) [elasticsearch-5.3.0.jar:5.3.0]
        at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-5.3.0.jar:5.3.0]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_111]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_111]
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_111]
Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('"' (code 34)): was expecting comma to separate Object entries
 at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@38662edf; line: 1, column: 34]
        at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1702) ~[jackson-core-2.8.6.jar:2.8.6]
        at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:558) ~[jackson-core-2.8.6.jar:2.8.6]
        at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:456) ~[jackson-core-2.8.6.jar:2.8.6]
        ... 49 more

(Nik Everett) #2

The """ construct is a kibana only thing. You'd have to do "{\"column21\":{\"...


(Agwani) #3

I have to pass value for column2 as a string, please suggest


(Nik Everett) #4

Escape the json into a json string.


(system) #5

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