You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2018/09/05 06:10:05 UTC

[camel] 01/02: CAMEL-12774 - Camel-elasticsearch-rest: Error during type conversion from type: java.lang.String to the required type: org.elasticsearch.action.update.UpdateRequest

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

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

commit fde4584efe2e9bc4adc78690a04e4b1083bf27ae
Author: Andrea Cosentino <an...@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 5dfce04..aea664e 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
@@ -59,7 +59,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 c97064d..be4d98b 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 {