Repository: camel
Updated Branches:
refs/heads/master 9827197a7 -> 6257769b5
CAMEL-9441: Camel-Elasticsearch: Add an operation to know if an index exists or not
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6257769b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6257769b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6257769b
Branch: refs/heads/master
Commit: 6257769b5ee3798da6a7af9bac89e3897771fb0f
Parents: 9827197
Author: Andrea Cosentino <ancosen@gmail.com>
Authored: Tue Dec 22 16:31:06 2015 +0100
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Tue Dec 22 16:32:29 2015 +0100
----------------------------------------------------------------------
.../camel/component/elasticsearch/ElasticsearchProducer.java | 2 +-
.../ElasticsearchGetSearchDeleteExistsUpdateTest.java | 7 ++++---
2 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/6257769b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchProducer.java
b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchProducer.java
index fbb2f7f..3e52607 100644
--- a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchProducer.java
+++ b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchProducer.java
@@ -156,7 +156,7 @@ public class ElasticsearchProducer extends DefaultProducer {
message.setBody(client.delete(deleteRequest).actionGet());
} else if (ElasticsearchConstants.OPERATION_EXISTS.equals(operation)) {
ExistsRequest existsRequest = message.getBody(ExistsRequest.class);
- message.setBody(client.exists(existsRequest).actionGet());
+ message.setBody(client.admin().indices().prepareExists(existsRequest.indices()).get().isExists());
} else if (ElasticsearchConstants.OPERATION_SEARCH.equals(operation)) {
SearchRequest searchRequest = message.getBody(SearchRequest.class);
message.setBody(client.search(searchRequest).actionGet());
http://git-wip-us.apache.org/repos/asf/camel/blob/6257769b/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java
b/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java
index 119c781..a70251d 100644
--- a/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java
+++ b/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java
@@ -139,9 +139,10 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest extends ElasticsearchB
//now, verify GET
headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_EXISTS);
- ExistsResponse response = template.requestBodyAndHeaders("direct:exists", "", headers,
ExistsResponse.class);
- assertNotNull("response should not be null", response);
- assertNotNull("response source should not be null", response.exists());
+ headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "twitter");
+ Boolean exists = template.requestBodyAndHeaders("direct:exists", "", headers, Boolean.class);
+ assertNotNull("response should not be null", exists);
+ assertTrue("Index should exists", exists);
}
@Test
|