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/11/07 12:17:14 UTC

[camel] 03/05: CAMEL-12749 - Added docs and removed the converter since it doesn't make sense to have one

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 9fe7baac9919abb27d3a227d4fc7973dcab77d7a
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Nov 7 13:15:34 2018 +0100

    CAMEL-12749 - Added docs and removed the converter since it doesn't make sense to have one
---
 .../main/docs/elasticsearch-rest-component.adoc    | 35 ++++++++++++++++++++++
 .../ElasticsearchActionRequestConverter.java       |  9 ------
 ...asticsearchGetSearchDeleteExistsUpdateTest.java |  2 +-
 3 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/components/camel-elasticsearch-rest/src/main/docs/elasticsearch-rest-component.adoc b/components/camel-elasticsearch-rest/src/main/docs/elasticsearch-rest-component.adoc
index caf07dc..0d3fbb4 100644
--- a/components/camel-elasticsearch-rest/src/main/docs/elasticsearch-rest-component.adoc
+++ b/components/camel-elasticsearch-rest/src/main/docs/elasticsearch-rest-component.adoc
@@ -154,6 +154,8 @@ object in the body
 
 |Search |*Map*, *String* or *SearchRequest* |Search the content with the map of query string
 
+|MultiSearch |*MultiSearchRequest* |Multiple search in one
+
 |Exists |Index name(indexName) as header  |Checks the index exists or not and returns a Boolean flag in the body
 
 |Update |*Map*, *UpdateRequest*, *String*, *byte[]* or *XContentBuilder* content to update |Updates content to an index and returns the content's
@@ -257,3 +259,36 @@ query.put("query", match);
 SearchHits response = template.requestBody("direct:search", query, SearchHits.class);
 
 ----
+
+=== MultiSearch Example
+
+MultiSearching on specific field(s) and value use the Operation ´MultiSearch´.
+Pass in the MultiSearchRequest instance
+
+[source,java]
+----
+from("direct:multiSearch")
+  .to("elasticsearch-rest://elasticsearch?operation=MultiSearch");
+----
+
+[source,xml]
+----
+<route>
+    <from uri="direct:multiSearch" />
+    <to uri="elasticsearch-rest://elasticsearch?operation=MultiSearch"/>
+</route>
+----
+
+MultiSearch on specific field(s) using Map.
+
+[source,java]
+----
+SearchRequest req = new SearchRequest();
+req.indices("twitter");
+req.types("tweet");
+SearchRequest req1 = new SearchRequest();
+req.indices("twitter");
+req.types("tweets");
+MultiSearchRequest request = new MultiSearchRequest().add(req1).add(req);
+Item[] response = template.requestBody("direct:search", request, Item[].class);
+----
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 9aab1b2..1347219 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
@@ -194,15 +194,6 @@ public final class ElasticsearchActionRequestConverter {
 
         return searchRequest;
     }
-    
-    @Converter
-    public static MultiSearchRequest toMultiSearchRequest(Object queryObject, Exchange exchange) throws IOException {
-        if (queryObject instanceof MultiSearchRequest) {
-            return (MultiSearchRequest) queryObject;
-        } else {
-            throw new IllegalArgumentException("Wrong body type. Only MultiSearchRequest is allowed as a type");
-        }
-    }
 
     @Converter
     public static BulkRequest toBulkRequest(Object documents, Exchange exchange) {
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 b8bf949..96e994f 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
@@ -322,7 +322,7 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest extends ElasticsearchB
                 from("direct:multiget").to("elasticsearch-rest://elasticsearch?operation=MultiGet&indexName=twitter&indexType=tweet&hostAddresses=localhost:" + ES_BASE_HTTP_PORT);
                 from("direct:delete").to("elasticsearch-rest://elasticsearch?operation=Delete&indexName=twitter&indexType=tweet&hostAddresses=localhost:" + ES_BASE_HTTP_PORT);
                 from("direct:search").to("elasticsearch-rest://elasticsearch?operation=Search&indexName=twitter&indexType=tweet&hostAddresses=localhost:" + ES_BASE_HTTP_PORT);
-                from("direct:multiSearch").to("elasticsearch-rest://elasticsearch?operation=MultiSearch&indexName=twitter&indexType=tweet&hostAddresses=localhost:" + ES_BASE_HTTP_PORT);
+                from("direct:multiSearch").to("elasticsearch-rest://elasticsearch?operation=MultiSearch&hostAddresses=localhost:" + ES_BASE_HTTP_PORT);
                 from("direct:update").to("elasticsearch-rest://elasticsearch?operation=Update&indexName=twitter&indexType=tweet&hostAddresses=localhost:" + ES_BASE_HTTP_PORT);
                 from("direct:exists").to("elasticsearch-rest://elasticsearch?operation=Exists&hostAddresses=localhost:" + ES_BASE_HTTP_PORT);
             }