This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch camel-2.21.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-2.21.x by this push:
     new aa37868  CAMEL-12774 - Camel-elasticsearch-rest: Error during type 
conversion from type: java.lang.String to the required type: 
org.elasticsearch.action.update.UpdateRequest
aa37868 is described below

commit aa37868ccfaad95439622872bd43d3fb9c92e84a
Author: Andrea Cosentino <anco...@gmail.com>
AuthorDate: Wed Sep 5 08:00:30 2018 +0200

    CAMEL-12774 - Camel-elasticsearch-rest: Error during type conversion from 
type: java.lang.String to the required type: 
org.elasticsearch.action.update.UpdateRequest
---
 .../converter/ElasticsearchActionRequestConverter.java     |  2 +-
 .../ElasticsearchGetSearchDeleteExistsUpdateTest.java      | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git 
a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/converter/ElasticsearchActionRequestConverter.java
 
b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/converter/ElasticsearchActionRequestConverter.java
index 7a2fe1d..3f4c120 100644
--- 
a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/converter/ElasticsearchActionRequestConverter.java
+++ 
b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/converter/ElasticsearchActionRequestConverter.java
@@ -62,7 +62,7 @@ public final class ElasticsearchActionRequestConverter {
         } else if (document instanceof Map) {
             updateRequest.doc((Map<String, Object>) document);
         } else if (document instanceof String) {
-            updateRequest.doc((String) document);
+            updateRequest.doc((String) document, 
XContentFactory.xContent((String) document));
         } else if (document instanceof XContentBuilder) {
             updateRequest.doc((XContentBuilder) document);
         } else {
diff --git 
a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java
 
b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java
index a6ac9f6..c99263a 100644
--- 
a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java
+++ 
b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java
@@ -270,6 +270,20 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest 
extends ElasticsearchB
         // then
         assertThat(response, notNullValue());
     }
+    
+    @Test
+    public void testStringUpdate() throws Exception {
+        Map<String, String> map = createIndexedData();
+        String indexId = template.requestBody("direct:index", map, 
String.class);
+        assertNotNull("indexId should be set", indexId);
+
+        String body = "{\"id\" : 1}";
+
+        Map<String, Object> headers = new HashMap<>();
+        headers.put(ElasticsearchConstants.PARAM_INDEX_ID, indexId);
+        indexId = template.requestBodyAndHeaders("direct:update", body, 
headers, String.class);
+        assertNotNull("indexId should be set", indexId);
+    }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {

Reply via email to