在Apache Camel Elasticsearch中使用GET请求时出现异常

时间:2017-11-10 12:18:48

标签: java elasticsearch apache-camel elasticsearch-java-api

描述:我必须使用Apache camel从Elasticsearch 5.4中读取特定字段。当我使用以下代码时,我无法查看回复

异常:从XContent构建toString时出错:com.fasterxml.jackson.core.JsonGenerationException:无法启动对象,期望字段名称(context:Object)

代码:

from("direct:start")
     .process(exchange -> {
        GetRequest a = new GetRequest("example", "doc", "1");
        exchange.getIn().setBody(a);
      })
     .to("elasticsearch5://elastic?operation=GET_BY_ID&ip=<ip>&port=9300")
     .log("${body}");

完成Stacktrace:

  

(route1)elasticsearch5:// elastic?ip =&amp; operation = GET_BY_ID&amp; port = 9300 - &gt; log [messageId]&lt;&lt;&lt;模式:InOnly,Headers:{breadcrumbId = ID-NLVHPRAAB02027-53300-1510315731625-0-1},BodyType:org.elasticsearch.action.support.PlainActionFuture,Body:从XContent构建toString时出错:com.fasterxml.jackson.core .JsonGenerationException:无法启动对象,期望字段名称(context:Object)       at com.fasterxml.jackson.core.JsonGenerator._reportError(JsonGenerator.java:1897)       at com.fasterxml.jackson.core.json.JsonGeneratorImpl._reportCantWriteValueExpectName(JsonGeneratorImpl.java:244)       在com.fasterxml.jackson.core.json.UTF8JsonGenerator._verifyValueWrite(UTF8JsonGenerator.java:1033)       at com.fasterxml.jackson.core.json.UTF8JsonGenerator.writeStartObject(UTF8JsonGenerator.java:313)       在org.elasticsearch.common.xcontent.json.JsonXContentGenerator.writeStartObject(JsonXContentGenerator.java:161)       在org.elasticsearch.common.xcontent.XContentBuilder.startObject(XContentBuilder.java:217)       在org.elasticsearch.index.get.GetResult.toXContent(GetResult.java:251)       at org.elasticsearch.action.get.GetResponse.toXContent(GetResponse.java:158)       在org.elasticsearch.common.Strings.toString(Strings.java:901)       at org.elastic ... [在1000个字符之后剪切,总长度为4350]

1 个答案:

答案 0 :(得分:1)