Update Indices Settings
@@ -1048,20 +632,6 @@ public final class IndicesClient {
UpdateSettingsResponse::fromXContent, listener, emptySet());
}
- /**
- * Asynchronously updates specific index level settings using the Update Indices Settings API.
- *
- * See Update Indices Settings
- * API on elastic.co
- * @deprecated Prefer {@link #putSettingsAsync(UpdateSettingsRequest, RequestOptions, ActionListener)}
- */
- @Deprecated
- public void putSettingsAsync(UpdateSettingsRequest updateSettingsRequest, ActionListener listener,
- Header... headers) {
- restHighLevelClient.performRequestAsyncAndParseEntity(updateSettingsRequest, RequestConverters::indexPutSettings,
- UpdateSettingsResponse::fromXContent, listener, emptySet(), headers);
- }
-
/**
* Puts an index template using the Index Templates API.
* See Index Templates API
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java
index 0084ce0f90d..536b85925a4 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java
@@ -296,17 +296,6 @@ public class RestHighLevelClient implements Closeable {
return performRequestAndParseEntity(bulkRequest, RequestConverters::bulk, options, BulkResponse::fromXContent, emptySet());
}
- /**
- * Executes a bulk request using the Bulk API.
- *
- * See Bulk API on elastic.co
- * @deprecated Prefer {@link #bulk(BulkRequest, RequestOptions)}
- */
- @Deprecated
- public final BulkResponse bulk(BulkRequest bulkRequest, Header... headers) throws IOException {
- return performRequestAndParseEntity(bulkRequest, RequestConverters::bulk, BulkResponse::fromXContent, emptySet(), headers);
- }
-
/**
* Asynchronously executes a bulk request using the Bulk API.
* See Bulk API on elastic.co
@@ -318,17 +307,6 @@ public class RestHighLevelClient implements Closeable {
performRequestAsyncAndParseEntity(bulkRequest, RequestConverters::bulk, options, BulkResponse::fromXContent, listener, emptySet());
}
- /**
- * Asynchronously executes a bulk request using the Bulk API.
- *
- * See Bulk API on elastic.co
- * @deprecated Prefer {@link #bulkAsync(BulkRequest, RequestOptions, ActionListener)}
- */
- @Deprecated
- public final void bulkAsync(BulkRequest bulkRequest, ActionListener listener, Header... headers) {
- performRequestAsyncAndParseEntity(bulkRequest, RequestConverters::bulk, BulkResponse::fromXContent, listener, emptySet(), headers);
- }
-
/**
* Pings the remote Elasticsearch cluster and returns true if the ping succeeded, false otherwise
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
@@ -340,16 +318,6 @@ public class RestHighLevelClient implements Closeable {
emptySet());
}
- /**
- * Pings the remote Elasticsearch cluster and returns true if the ping succeeded, false otherwise
- * @deprecated Prefer {@link #ping(RequestOptions)}
- */
- @Deprecated
- public final boolean ping(Header... headers) throws IOException {
- return performRequest(new MainRequest(), (request) -> RequestConverters.ping(), RestHighLevelClient::convertExistsResponse,
- emptySet(), headers);
- }
-
/**
* Get the cluster info otherwise provided when sending an HTTP request to '/'
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
@@ -361,16 +329,6 @@ public class RestHighLevelClient implements Closeable {
MainResponse::fromXContent, emptySet());
}
- /**
- * Get the cluster info otherwise provided when sending an HTTP request to port 9200
- * @deprecated Prefer {@link #info(RequestOptions)}
- */
- @Deprecated
- public final MainResponse info(Header... headers) throws IOException {
- return performRequestAndParseEntity(new MainRequest(), (request) -> RequestConverters.info(),
- MainResponse::fromXContent, emptySet(), headers);
- }
-
/**
* Retrieves a document by id using the Get API.
* See Get API on elastic.co
@@ -383,17 +341,6 @@ public class RestHighLevelClient implements Closeable {
return performRequestAndParseEntity(getRequest, RequestConverters::get, options, GetResponse::fromXContent, singleton(404));
}
- /**
- * Retrieves a document by id using the Get API.
- *
- * See Get API on elastic.co
- * @deprecated Prefer {@link #get(GetRequest, RequestOptions)}
- */
- @Deprecated
- public final GetResponse get(GetRequest getRequest, Header... headers) throws IOException {
- return performRequestAndParseEntity(getRequest, RequestConverters::get, GetResponse::fromXContent, singleton(404), headers);
- }
-
/**
* Asynchronously retrieves a document by id using the Get API.
* See Get API on elastic.co
@@ -406,18 +353,6 @@ public class RestHighLevelClient implements Closeable {
singleton(404));
}
- /**
- * Asynchronously retrieves a document by id using the Get API.
- *
- * See Get API on elastic.co
- * @deprecated Prefer {@link #getAsync(GetRequest, RequestOptions, ActionListener)}
- */
- @Deprecated
- public final void getAsync(GetRequest getRequest, ActionListener listener, Header... headers) {
- performRequestAsyncAndParseEntity(getRequest, RequestConverters::get, GetResponse::fromXContent, listener,
- singleton(404), headers);
- }
-
/**
* Retrieves multiple documents by id using the Multi Get API.
* See Multi Get API on elastic.co
@@ -431,18 +366,6 @@ public class RestHighLevelClient implements Closeable {
singleton(404));
}
- /**
- * Retrieves multiple documents by id using the Multi Get API.
- *
- * See Multi Get API on elastic.co
- * @deprecated Prefer {@link #multiGet(MultiGetRequest, RequestOptions)}
- */
- @Deprecated
- public final MultiGetResponse multiGet(MultiGetRequest multiGetRequest, Header... headers) throws IOException {
- return performRequestAndParseEntity(multiGetRequest, RequestConverters::multiGet, MultiGetResponse::fromXContent,
- singleton(404), headers);
- }
-
/**
* Asynchronously retrieves multiple documents by id using the Multi Get API.
* See Multi Get API on elastic.co
@@ -455,18 +378,6 @@ public class RestHighLevelClient implements Closeable {
singleton(404));
}
- /**
- * Asynchronously retrieves multiple documents by id using the Multi Get API.
- *
- * See Multi Get API on elastic.co
- * @deprecated Prefer {@link #multiGetAsync(MultiGetRequest, RequestOptions, ActionListener)}
- */
- @Deprecated
- public final void multiGetAsync(MultiGetRequest multiGetRequest, ActionListener listener, Header... headers) {
- performRequestAsyncAndParseEntity(multiGetRequest, RequestConverters::multiGet, MultiGetResponse::fromXContent, listener,
- singleton(404), headers);
- }
-
/**
* Checks for the existence of a document. Returns true if it exists, false otherwise.
* See Get API on elastic.co
@@ -479,17 +390,6 @@ public class RestHighLevelClient implements Closeable {
return performRequest(getRequest, RequestConverters::exists, options, RestHighLevelClient::convertExistsResponse, emptySet());
}
- /**
- * Checks for the existence of a document. Returns true if it exists, false otherwise.
- *
- * See Get API on elastic.co
- * @deprecated Prefer {@link #exists(GetRequest, RequestOptions)}
- */
- @Deprecated
- public final boolean exists(GetRequest getRequest, Header... headers) throws IOException {
- return performRequest(getRequest, RequestConverters::exists, RestHighLevelClient::convertExistsResponse, emptySet(), headers);
- }
-
/**
* Asynchronously checks for the existence of a document. Returns true if it exists, false otherwise.
* See Get API on elastic.co
@@ -502,18 +402,6 @@ public class RestHighLevelClient implements Closeable {
emptySet());
}
- /**
- * Asynchronously checks for the existence of a document. Returns true if it exists, false otherwise.
- *
- * See Get API on elastic.co
- * @deprecated Prefer {@link #existsAsync(GetRequest, RequestOptions, ActionListener)}
- */
- @Deprecated
- public final void existsAsync(GetRequest getRequest, ActionListener listener, Header... headers) {
- performRequestAsync(getRequest, RequestConverters::exists, RestHighLevelClient::convertExistsResponse, listener,
- emptySet(), headers);
- }
-
/**
* Index a document using the Index API.
* See Index API on elastic.co
@@ -526,17 +414,6 @@ public class RestHighLevelClient implements Closeable {
return performRequestAndParseEntity(indexRequest, RequestConverters::index, options, IndexResponse::fromXContent, emptySet());
}
- /**
- * Index a document using the Index API.
- *
- * See Index API on elastic.co
- * @deprecated Prefer {@link #index(IndexRequest, RequestOptions)}
- */
- @Deprecated
- public final IndexResponse index(IndexRequest indexRequest, Header... headers) throws IOException {
- return performRequestAndParseEntity(indexRequest, RequestConverters::index, IndexResponse::fromXContent, emptySet(), headers);
- }
-
/**
* Asynchronously index a document using the Index API.
* See Index API on elastic.co
@@ -549,18 +426,6 @@ public class RestHighLevelClient implements Closeable {
emptySet());
}
- /**
- * Asynchronously index a document using the Index API.
- *
- * See Index API on elastic.co
- * @deprecated Prefer {@link #indexAsync(IndexRequest, RequestOptions, ActionListener)}
- */
- @Deprecated
- public final void indexAsync(IndexRequest indexRequest, ActionListener listener, Header... headers) {
- performRequestAsyncAndParseEntity(indexRequest, RequestConverters::index, IndexResponse::fromXContent, listener,
- emptySet(), headers);
- }
-
/**
* Updates a document using the Update API.
* See Update API on elastic.co
@@ -573,17 +438,6 @@ public class RestHighLevelClient implements Closeable {
return performRequestAndParseEntity(updateRequest, RequestConverters::update, options, UpdateResponse::fromXContent, emptySet());
}
- /**
- * Updates a document using the Update API.
- *
- * See Update API on elastic.co
- * @deprecated Prefer {@link #update(UpdateRequest, RequestOptions)}
- */
- @Deprecated
- public final UpdateResponse update(UpdateRequest updateRequest, Header... headers) throws IOException {
- return performRequestAndParseEntity(updateRequest, RequestConverters::update, UpdateResponse::fromXContent, emptySet(), headers);
- }
-
/**
* Asynchronously updates a document using the Update API.
* See Update API on elastic.co
@@ -596,18 +450,6 @@ public class RestHighLevelClient implements Closeable {
emptySet());
}
- /**
- * Asynchronously updates a document using the Update API.
- *
- * See Update API on elastic.co
- * @deprecated Prefer {@link #updateAsync(UpdateRequest, RequestOptions, ActionListener)}
- */
- @Deprecated
- public final void updateAsync(UpdateRequest updateRequest, ActionListener listener, Header... headers) {
- performRequestAsyncAndParseEntity(updateRequest, RequestConverters::update, UpdateResponse::fromXContent, listener,
- emptySet(), headers);
- }
-
/**
* Deletes a document by id using the Delete API.
* See Delete API on elastic.co
@@ -621,18 +463,6 @@ public class RestHighLevelClient implements Closeable {
singleton(404));
}
- /**
- * Deletes a document by id using the Delete API.
- *
- * See Delete API on elastic.co
- * @deprecated Prefer {@link #delete(DeleteRequest, RequestOptions)}
- */
- @Deprecated
- public final DeleteResponse delete(DeleteRequest deleteRequest, Header... headers) throws IOException {
- return performRequestAndParseEntity(deleteRequest, RequestConverters::delete, DeleteResponse::fromXContent,
- singleton(404), headers);
- }
-
/**
* Asynchronously deletes a document by id using the Delete API.
* See Delete API on elastic.co
@@ -645,18 +475,6 @@ public class RestHighLevelClient implements Closeable {
Collections.singleton(404));
}
- /**
- * Asynchronously deletes a document by id using the Delete API.
- *
- * See Delete API on elastic.co
- * @deprecated Prefer {@link #deleteAsync(DeleteRequest, RequestOptions, ActionListener)}
- */
- @Deprecated
- public final void deleteAsync(DeleteRequest deleteRequest, ActionListener listener, Header... headers) {
- performRequestAsyncAndParseEntity(deleteRequest, RequestConverters::delete, DeleteResponse::fromXContent, listener,
- Collections.singleton(404), headers);
- }
-
/**
* Executes a search request using the Search API.
* See Search API on elastic.co
@@ -669,17 +487,6 @@ public class RestHighLevelClient implements Closeable {
return performRequestAndParseEntity(searchRequest, RequestConverters::search, options, SearchResponse::fromXContent, emptySet());
}
- /**
- * Executes a search using the Search API.
- *
- * See Search API on elastic.co
- * @deprecated Prefer {@link #search(SearchRequest, RequestOptions)}
- */
- @Deprecated
- public final SearchResponse search(SearchRequest searchRequest, Header... headers) throws IOException {
- return performRequestAndParseEntity(searchRequest, RequestConverters::search, SearchResponse::fromXContent, emptySet(), headers);
- }
-
/**
* Asynchronously executes a search using the Search API.
* See Search API on elastic.co
@@ -692,18 +499,6 @@ public class RestHighLevelClient implements Closeable {
emptySet());
}
- /**
- * Asynchronously executes a search using the Search API.
- *
- * See Search API on elastic.co
- * @deprecated Prefer {@link #searchAsync(SearchRequest, RequestOptions, ActionListener)}
- */
- @Deprecated
- public final void searchAsync(SearchRequest searchRequest, ActionListener listener, Header... headers) {
- performRequestAsyncAndParseEntity(searchRequest, RequestConverters::search, SearchResponse::fromXContent, listener,
- emptySet(), headers);
- }
-
/**
* Executes a multi search using the msearch API.
* See Multi search API on
@@ -718,19 +513,6 @@ public class RestHighLevelClient implements Closeable {
emptySet());
}
- /**
- * Executes a multi search using the msearch API.
- *
- * See Multi search API on
- * elastic.co
- * @deprecated Prefer {@link #multiSearch(MultiSearchRequest, RequestOptions)}
- */
- @Deprecated
- public final MultiSearchResponse multiSearch(MultiSearchRequest multiSearchRequest, Header... headers) throws IOException {
- return performRequestAndParseEntity(multiSearchRequest, RequestConverters::multiSearch, MultiSearchResponse::fromXContext,
- emptySet(), headers);
- }
-
/**
* Asynchronously executes a multi search using the msearch API.
* See Multi search API on
@@ -745,19 +527,6 @@ public class RestHighLevelClient implements Closeable {
listener, emptySet());
}
- /**
- * Asynchronously executes a multi search using the msearch API.
- *
- * See Multi search API on
- * elastic.co
- * @deprecated Prefer {@link #multiSearchAsync(MultiSearchRequest, RequestOptions, ActionListener)}
- */
- @Deprecated
- public final void multiSearchAsync(MultiSearchRequest searchRequest, ActionListener listener, Header... headers) {
- performRequestAsyncAndParseEntity(searchRequest, RequestConverters::multiSearch, MultiSearchResponse::fromXContext, listener,
- emptySet(), headers);
- }
-
/**
* Executes a search using the Search Scroll API.
* See Search Scroll
@@ -772,19 +541,6 @@ public class RestHighLevelClient implements Closeable {
emptySet());
}
- /**
- * Executes a search using the Search Scroll API.
- *
- * See Search Scroll
- * API on elastic.co
- * @deprecated Prefer {@link #searchScroll(SearchScrollRequest, RequestOptions)}
- */
- @Deprecated
- public final SearchResponse searchScroll(SearchScrollRequest searchScrollRequest, Header... headers) throws IOException {
- return performRequestAndParseEntity(searchScrollRequest, RequestConverters::searchScroll, SearchResponse::fromXContent,
- emptySet(), headers);
- }
-
/**
* Asynchronously executes a search using the Search Scroll API.
* See Search Scroll
@@ -799,20 +555,6 @@ public class RestHighLevelClient implements Closeable {
listener, emptySet());
}
- /**
- * Asynchronously executes a search using the Search Scroll API.
- *
- * See Search Scroll
- * API on elastic.co
- * @deprecated Prefer {@link #searchScrollAsync(SearchScrollRequest, RequestOptions, ActionListener)}
- */
- @Deprecated
- public final void searchScrollAsync(SearchScrollRequest searchScrollRequest,
- ActionListener listener, Header... headers) {
- performRequestAsyncAndParseEntity(searchScrollRequest, RequestConverters::searchScroll, SearchResponse::fromXContent,
- listener, emptySet(), headers);
- }
-
/**
* Clears one or more scroll ids using the Clear Scroll API.
* See
@@ -827,19 +569,6 @@ public class RestHighLevelClient implements Closeable {
emptySet());
}
- /**
- * Clears one or more scroll ids using the Clear Scroll API.
- *
- * See
- * Clear Scroll API on elastic.co
- * @deprecated Prefer {@link #clearScroll(ClearScrollRequest, RequestOptions)}
- */
- @Deprecated
- public final ClearScrollResponse clearScroll(ClearScrollRequest clearScrollRequest, Header... headers) throws IOException {
- return performRequestAndParseEntity(clearScrollRequest, RequestConverters::clearScroll, ClearScrollResponse::fromXContent,
- emptySet(), headers);
- }
-
/**
* Asynchronously clears one or more scroll ids using the Clear Scroll API.
* See
@@ -854,20 +583,6 @@ public class RestHighLevelClient implements Closeable {
listener, emptySet());
}
- /**
- * Asynchronously clears one or more scroll ids using the Clear Scroll API.
- *
- * See
- * Clear Scroll API on elastic.co
- * @deprecated Prefer {@link #clearScrollAsync(ClearScrollRequest, RequestOptions, ActionListener)}
- */
- @Deprecated
- public final void clearScrollAsync(ClearScrollRequest clearScrollRequest,
- ActionListener listener, Header... headers) {
- performRequestAsyncAndParseEntity(clearScrollRequest, RequestConverters::clearScroll, ClearScrollResponse::fromXContent,
- listener, emptySet(), headers);
- }
-
/**
* Executes a request using the Search Template API.
* See Search Template API
@@ -909,19 +624,6 @@ public class RestHighLevelClient implements Closeable {
emptySet());
}
- /**
- * Executes a request using the Ranking Evaluation API.
- *
- * See Ranking Evaluation API
- * on elastic.co
- * @deprecated Prefer {@link #rankEval(RankEvalRequest, RequestOptions)}
- */
- @Deprecated
- public final RankEvalResponse rankEval(RankEvalRequest rankEvalRequest, Header... headers) throws IOException {
- return performRequestAndParseEntity(rankEvalRequest, RequestConverters::rankEval, RankEvalResponse::fromXContent,
- emptySet(), headers);
- }
-
/**
* Asynchronously executes a request using the Ranking Evaluation API.
* See Ranking Evaluation API
@@ -935,19 +637,6 @@ public class RestHighLevelClient implements Closeable {
emptySet());
}
- /**
- * Asynchronously executes a request using the Ranking Evaluation API.
- *
- * See Ranking Evaluation API
- * on elastic.co
- * @deprecated Prefer {@link #rankEvalAsync(RankEvalRequest, RequestOptions, ActionListener)}
- */
- @Deprecated
- public final void rankEvalAsync(RankEvalRequest rankEvalRequest, ActionListener listener, Header... headers) {
- performRequestAsyncAndParseEntity(rankEvalRequest, RequestConverters::rankEval, RankEvalResponse::fromXContent, listener,
- emptySet(), headers);
- }
-
/**
* Executes a request using the Field Capabilities API.
* See Field Capabilities API
@@ -977,14 +666,6 @@ public class RestHighLevelClient implements Closeable {
FieldCapabilitiesResponse::fromXContent, listener, emptySet());
}
- @Deprecated
- protected final Resp performRequestAndParseEntity(Req request,
- CheckedFunction requestConverter,
- CheckedFunction entityParser,
- Set ignores, Header... headers) throws IOException {
- return performRequest(request, requestConverter, (response) -> parseEntity(response.getEntity(), entityParser), ignores, headers);
- }
-
protected final Resp performRequestAndParseEntity(Req request,
CheckedFunction requestConverter,
RequestOptions options,
@@ -994,14 +675,6 @@ public class RestHighLevelClient implements Closeable {
response -> parseEntity(response.getEntity(), entityParser), ignores);
}
- @Deprecated
- protected final Resp performRequest(Req request,
- CheckedFunction requestConverter,
- CheckedFunction responseConverter,
- Set ignores, Header... headers) throws IOException {
- return performRequest(request, requestConverter, optionsForHeaders(headers), responseConverter, ignores);
- }
-
protected final Resp performRequest(Req request,
CheckedFunction requestConverter,
RequestOptions options,
@@ -1038,15 +711,6 @@ public class RestHighLevelClient implements Closeable {
}
}
- @Deprecated
- protected final void performRequestAsyncAndParseEntity(Req request,
- CheckedFunction requestConverter,
- CheckedFunction entityParser,
- ActionListener listener, Set ignores, Header... headers) {
- performRequestAsync(request, requestConverter, (response) -> parseEntity(response.getEntity(), entityParser),
- listener, ignores, headers);
- }
-
protected final void performRequestAsyncAndParseEntity(Req request,
CheckedFunction requestConverter,
RequestOptions options,
@@ -1056,14 +720,6 @@ public class RestHighLevelClient implements Closeable {
response -> parseEntity(response.getEntity(), entityParser), listener, ignores);
}
- @Deprecated
- protected final void performRequestAsync(Req request,
- CheckedFunction requestConverter,
- CheckedFunction responseConverter,
- ActionListener listener, Set ignores, Header... headers) {
- performRequestAsync(request, requestConverter, optionsForHeaders(headers), responseConverter, listener, ignores);
- }
-
protected final void performRequestAsync(Req request,
CheckedFunction requestConverter,
RequestOptions options,
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/TasksClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/TasksClient.java
index f8f03d7f7d2..ebba636b8fa 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/TasksClient.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/TasksClient.java
@@ -84,7 +84,7 @@ public final class TasksClient {
cancelTasksRequest,
RequestConverters::cancelTasks,
options,
- parser -> CancelTasksResponse.fromXContent(parser),
+ CancelTasksResponse::fromXContent,
emptySet()
);
}
@@ -103,7 +103,7 @@ public final class TasksClient {
cancelTasksRequest,
RequestConverters::cancelTasks,
options,
- parser -> CancelTasksResponse.fromXContent(parser),
+ CancelTasksResponse::fromXContent,
listener,
emptySet()
);
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java
index d41c47177f9..7605b1c715c 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java
@@ -56,7 +56,8 @@ import static org.hamcrest.Matchers.lessThanOrEqualTo;
public class BulkProcessorIT extends ESRestHighLevelClientTestCase {
private static BulkProcessor.Builder initBulkProcessorBuilder(BulkProcessor.Listener listener) {
- return BulkProcessor.builder(highLevelClient()::bulkAsync, listener);
+ return BulkProcessor.builder(
+ (request, bulkListener) -> highLevelClient().bulkAsync(request, RequestOptions.DEFAULT, bulkListener), listener);
}
public void testThatBulkProcessorCountIsCorrect() throws Exception {
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorRetryIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorRetryIT.java
index fe6aa6b1017..c20998eeb58 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorRetryIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorRetryIT.java
@@ -48,7 +48,8 @@ public class BulkProcessorRetryIT extends ESRestHighLevelClientTestCase {
private static final String TYPE_NAME = "type";
private static BulkProcessor.Builder initBulkProcessorBuilder(BulkProcessor.Listener listener) {
- return BulkProcessor.builder(highLevelClient()::bulkAsync, listener);
+ return BulkProcessor.builder(
+ (request, bulkListener) -> highLevelClient().bulkAsync(request, RequestOptions.DEFAULT, bulkListener), listener);
}
public void testBulkRejectionLoadWithoutBackoff() throws Exception {
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/ClusterClientIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/ClusterClientIT.java
index 7cf9fca07c3..2ae6f9dc186 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/ClusterClientIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/ClusterClientIT.java
@@ -63,7 +63,6 @@ public class ClusterClientIT extends ESRestHighLevelClientTestCase {
setRequest.persistentSettings(map);
ClusterUpdateSettingsResponse setResponse = execute(setRequest, highLevelClient().cluster()::putSettings,
- highLevelClient().cluster()::putSettingsAsync, highLevelClient().cluster()::putSettings,
highLevelClient().cluster()::putSettingsAsync);
assertAcked(setResponse);
@@ -86,7 +85,6 @@ public class ClusterClientIT extends ESRestHighLevelClientTestCase {
resetRequest.persistentSettings("{\"" + persistentSettingKey + "\": null }", XContentType.JSON);
ClusterUpdateSettingsResponse resetResponse = execute(resetRequest, highLevelClient().cluster()::putSettings,
- highLevelClient().cluster()::putSettingsAsync, highLevelClient().cluster()::putSettings,
highLevelClient().cluster()::putSettingsAsync);
assertThat(resetResponse.getTransientSettings().get(transientSettingKey), equalTo(null));
@@ -108,7 +106,6 @@ public class ClusterClientIT extends ESRestHighLevelClientTestCase {
clusterUpdateSettingsRequest.transientSettings(Settings.builder().put(setting, value).build());
ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> execute(clusterUpdateSettingsRequest,
- highLevelClient().cluster()::putSettings, highLevelClient().cluster()::putSettingsAsync,
highLevelClient().cluster()::putSettings, highLevelClient().cluster()::putSettingsAsync));
assertThat(exception.status(), equalTo(RestStatus.BAD_REQUEST));
assertThat(exception.getMessage(), equalTo(
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java
index 81c894f242f..9de4c22611c 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java
@@ -74,8 +74,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
if (randomBoolean()) {
deleteRequest.version(1L);
}
- DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync,
- highLevelClient()::delete, highLevelClient()::deleteAsync);
+ DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync);
assertEquals("index", deleteResponse.getIndex());
assertEquals("type", deleteResponse.getType());
assertEquals(docId, deleteResponse.getId());
@@ -85,8 +84,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
// Testing non existing document
String docId = "does_not_exist";
DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId);
- DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync,
- highLevelClient()::delete, highLevelClient()::deleteAsync);
+ DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync);
assertEquals("index", deleteResponse.getIndex());
assertEquals("type", deleteResponse.getType());
assertEquals(docId, deleteResponse.getId());
@@ -99,8 +97,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar")), RequestOptions.DEFAULT);
DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId).version(2);
ElasticsearchException exception = expectThrows(ElasticsearchException.class,
- () -> execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync,
- highLevelClient()::delete, highLevelClient()::deleteAsync));
+ () -> execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync));
assertEquals(RestStatus.CONFLICT, exception.status());
assertEquals("Elasticsearch exception [type=version_conflict_engine_exception, reason=[type][" + docId + "]: " +
"version conflict, current version [1] is different than the one provided [2]]", exception.getMessage());
@@ -113,8 +110,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar"))
.versionType(VersionType.EXTERNAL).version(12), RequestOptions.DEFAULT);
DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId).versionType(VersionType.EXTERNAL).version(13);
- DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync,
- highLevelClient()::delete, highLevelClient()::deleteAsync);
+ DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync);
assertEquals("index", deleteResponse.getIndex());
assertEquals("type", deleteResponse.getType());
assertEquals(docId, deleteResponse.getId());
@@ -128,8 +124,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
.versionType(VersionType.EXTERNAL).version(12), RequestOptions.DEFAULT);
ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> {
DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId).versionType(VersionType.EXTERNAL).version(10);
- execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync,
- highLevelClient()::delete, highLevelClient()::deleteAsync);
+ execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync);
});
assertEquals(RestStatus.CONFLICT, exception.status());
assertEquals("Elasticsearch exception [type=version_conflict_engine_exception, reason=[type][" +
@@ -142,8 +137,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
highLevelClient().index(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar")).routing("foo"),
RequestOptions.DEFAULT);
DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId).routing("foo");
- DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync,
- highLevelClient()::delete, highLevelClient()::deleteAsync);
+ DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync);
assertEquals("index", deleteResponse.getIndex());
assertEquals("type", deleteResponse.getType());
assertEquals(docId, deleteResponse.getId());
@@ -154,8 +148,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
public void testExists() throws IOException {
{
GetRequest getRequest = new GetRequest("index", "type", "id");
- assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync,
- highLevelClient()::exists, highLevelClient()::existsAsync));
+ assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync));
}
IndexRequest index = new IndexRequest("index", "type", "id");
index.source("{\"field1\":\"value1\",\"field2\":\"value2\"}", XContentType.JSON);
@@ -163,18 +156,15 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
highLevelClient().index(index, RequestOptions.DEFAULT);
{
GetRequest getRequest = new GetRequest("index", "type", "id");
- assertTrue(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync,
- highLevelClient()::exists, highLevelClient()::existsAsync));
+ assertTrue(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync));
}
{
GetRequest getRequest = new GetRequest("index", "type", "does_not_exist");
- assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync,
- highLevelClient()::exists, highLevelClient()::existsAsync));
+ assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync));
}
{
GetRequest getRequest = new GetRequest("index", "type", "does_not_exist").version(1);
- assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync,
- highLevelClient()::exists, highLevelClient()::existsAsync));
+ assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync));
}
}
@@ -182,8 +172,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
{
GetRequest getRequest = new GetRequest("index", "type", "id");
ElasticsearchException exception = expectThrows(ElasticsearchException.class,
- () -> execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync,
- highLevelClient()::get, highLevelClient()::getAsync));
+ () -> execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync));
assertEquals(RestStatus.NOT_FOUND, exception.status());
assertEquals("Elasticsearch exception [type=index_not_found_exception, reason=no such index]", exception.getMessage());
assertEquals("index", exception.getMetadata("es.index").get(0));
@@ -196,8 +185,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
{
GetRequest getRequest = new GetRequest("index", "type", "id").version(2);
ElasticsearchException exception = expectThrows(ElasticsearchException.class,
- () -> execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync,
- highLevelClient()::get, highLevelClient()::getAsync));
+ () -> execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync));
assertEquals(RestStatus.CONFLICT, exception.status());
assertEquals("Elasticsearch exception [type=version_conflict_engine_exception, " + "reason=[type][id]: " +
"version conflict, current version [1] is different than the one provided [2]]", exception.getMessage());
@@ -208,8 +196,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
if (randomBoolean()) {
getRequest.version(1L);
}
- GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync,
- highLevelClient()::get, highLevelClient()::getAsync);
+ GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync);
assertEquals("index", getResponse.getIndex());
assertEquals("type", getResponse.getType());
assertEquals("id", getResponse.getId());
@@ -220,8 +207,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
}
{
GetRequest getRequest = new GetRequest("index", "type", "does_not_exist");
- GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync,
- highLevelClient()::get, highLevelClient()::getAsync);
+ GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync);
assertEquals("index", getResponse.getIndex());
assertEquals("type", getResponse.getType());
assertEquals("does_not_exist", getResponse.getId());
@@ -233,8 +219,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
{
GetRequest getRequest = new GetRequest("index", "type", "id");
getRequest.fetchSourceContext(new FetchSourceContext(false, Strings.EMPTY_ARRAY, Strings.EMPTY_ARRAY));
- GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync,
- highLevelClient()::get, highLevelClient()::getAsync);
+ GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync);
assertEquals("index", getResponse.getIndex());
assertEquals("type", getResponse.getType());
assertEquals("id", getResponse.getId());
@@ -250,8 +235,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
} else {
getRequest.fetchSourceContext(new FetchSourceContext(true, Strings.EMPTY_ARRAY, new String[]{"field2"}));
}
- GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync,
- highLevelClient()::get, highLevelClient()::getAsync);
+ GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync);
assertEquals("index", getResponse.getIndex());
assertEquals("type", getResponse.getType());
assertEquals("id", getResponse.getId());
@@ -269,8 +253,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
MultiGetRequest multiGetRequest = new MultiGetRequest();
multiGetRequest.add("index", "type", "id1");
multiGetRequest.add("index", "type", "id2");
- MultiGetResponse response = execute(multiGetRequest, highLevelClient()::multiGet, highLevelClient()::multiGetAsync,
- highLevelClient()::multiGet, highLevelClient()::multiGetAsync);
+ MultiGetResponse response = execute(multiGetRequest, highLevelClient()::multiGet, highLevelClient()::multiGetAsync);
assertEquals(2, response.getResponses().length);
assertTrue(response.getResponses()[0].isFailed());
@@ -302,8 +285,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
MultiGetRequest multiGetRequest = new MultiGetRequest();
multiGetRequest.add("index", "type", "id1");
multiGetRequest.add("index", "type", "id2");
- MultiGetResponse response = execute(multiGetRequest, highLevelClient()::multiGet, highLevelClient()::multiGetAsync,
- highLevelClient()::multiGet, highLevelClient()::multiGetAsync);
+ MultiGetResponse response = execute(multiGetRequest, highLevelClient()::multiGet, highLevelClient()::multiGetAsync);
assertEquals(2, response.getResponses().length);
assertFalse(response.getResponses()[0].isFailed());
@@ -328,8 +310,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
IndexRequest indexRequest = new IndexRequest("index", "type");
indexRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("test", "test").endObject());
- IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync,
- highLevelClient()::index, highLevelClient()::indexAsync);
+ IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync);
assertEquals(RestStatus.CREATED, indexResponse.status());
assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult());
assertEquals("index", indexResponse.getIndex());
@@ -350,8 +331,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
IndexRequest indexRequest = new IndexRequest("index", "type", "id");
indexRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("version", 1).endObject());
- IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync,
- highLevelClient()::index, highLevelClient()::indexAsync);
+ IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync);
assertEquals(RestStatus.CREATED, indexResponse.status());
assertEquals("index", indexResponse.getIndex());
assertEquals("type", indexResponse.getType());
@@ -361,8 +341,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
indexRequest = new IndexRequest("index", "type", "id");
indexRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("version", 2).endObject());
- indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync,
- highLevelClient()::index, highLevelClient()::indexAsync);
+ indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync);
assertEquals(RestStatus.OK, indexResponse.status());
assertEquals("index", indexResponse.getIndex());
assertEquals("type", indexResponse.getType());
@@ -374,8 +353,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
wrongRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("field", "test").endObject());
wrongRequest.version(5L);
- execute(wrongRequest, highLevelClient()::index, highLevelClient()::indexAsync,
- highLevelClient()::index, highLevelClient()::indexAsync);
+ execute(wrongRequest, highLevelClient()::index, highLevelClient()::indexAsync);
});
assertEquals(RestStatus.CONFLICT, exception.status());
assertEquals("Elasticsearch exception [type=version_conflict_engine_exception, reason=[type][id]: " +
@@ -388,8 +366,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
indexRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("field", "test").endObject());
indexRequest.setPipeline("missing");
- execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync,
- highLevelClient()::index, highLevelClient()::indexAsync);
+ execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync);
});
assertEquals(RestStatus.BAD_REQUEST, exception.status());
@@ -402,8 +379,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
indexRequest.version(12L);
indexRequest.versionType(VersionType.EXTERNAL);
- IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync,
- highLevelClient()::index, highLevelClient()::indexAsync);
+ IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync);
assertEquals(RestStatus.CREATED, indexResponse.status());
assertEquals("index", indexResponse.getIndex());
assertEquals("type", indexResponse.getType());
@@ -415,16 +391,14 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
indexRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("field", "test").endObject());
indexRequest.opType(DocWriteRequest.OpType.CREATE);
- IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync,
- highLevelClient()::index, highLevelClient()::indexAsync);
+ IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync);
assertEquals(RestStatus.CREATED, indexResponse.status());
assertEquals("index", indexResponse.getIndex());
assertEquals("type", indexResponse.getType());
assertEquals("with_create_op_type", indexResponse.getId());
ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> {
- execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync,
- highLevelClient()::index, highLevelClient()::indexAsync);
+ execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync);
});
assertEquals(RestStatus.CONFLICT, exception.status());
@@ -439,8 +413,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
updateRequest.doc(singletonMap("field", "value"), randomFrom(XContentType.values()));
ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () ->
- execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync,
- highLevelClient()::update, highLevelClient()::updateAsync));
+ execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync));
assertEquals(RestStatus.NOT_FOUND, exception.status());
assertEquals("Elasticsearch exception [type=document_missing_exception, reason=[type][does_not_exist]: document missing]",
exception.getMessage());
@@ -463,8 +436,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
updateRequestConflict.version(indexResponse.getVersion());
ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () ->
- execute(updateRequestConflict, highLevelClient()::update, highLevelClient()::updateAsync,
- highLevelClient()::update, highLevelClient()::updateAsync));
+ execute(updateRequestConflict, highLevelClient()::update, highLevelClient()::updateAsync));
assertEquals(RestStatus.CONFLICT, exception.status());
assertEquals("Elasticsearch exception [type=version_conflict_engine_exception, reason=[type][id]: version conflict, " +
"current version [2] is different than the one provided [1]]", exception.getMessage());
@@ -480,8 +452,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
updateRequest.script(script);
updateRequest.fetchSource(true);
- UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync,
- highLevelClient()::update, highLevelClient()::updateAsync);
+ UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync);
assertEquals(RestStatus.OK, updateResponse.status());
assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult());
assertEquals(2L, updateResponse.getVersion());
@@ -501,8 +472,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
updateRequest.doc(singletonMap("field_2", "two"), randomFrom(XContentType.values()));
updateRequest.fetchSource("field_*", "field_3");
- UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync,
- highLevelClient()::update, highLevelClient()::updateAsync);
+ UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync);
assertEquals(RestStatus.OK, updateResponse.status());
assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult());
assertEquals(13L, updateResponse.getVersion());
@@ -523,8 +493,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
UpdateRequest updateRequest = new UpdateRequest("index", "type", "noop");
updateRequest.doc(singletonMap("field", "value"), randomFrom(XContentType.values()));
- UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync,
- highLevelClient()::update, highLevelClient()::updateAsync);
+ UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync);
assertEquals(RestStatus.OK, updateResponse.status());
assertEquals(DocWriteResponse.Result.NOOP, updateResponse.getResult());
assertEquals(1L, updateResponse.getVersion());
@@ -542,8 +511,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
updateRequest.doc(singletonMap("doc_status", "updated"));
updateRequest.fetchSource(true);
- UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync,
- highLevelClient()::update, highLevelClient()::updateAsync);
+ UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync);
assertEquals(RestStatus.CREATED, updateResponse.status());
assertEquals("index", updateResponse.getIndex());
assertEquals("type", updateResponse.getType());
@@ -558,8 +526,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
updateRequest.fetchSource(true);
updateRequest.docAsUpsert(true);
- UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync,
- highLevelClient()::update, highLevelClient()::updateAsync);
+ UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync);
assertEquals(RestStatus.CREATED, updateResponse.status());
assertEquals("index", updateResponse.getIndex());
assertEquals("type", updateResponse.getType());
@@ -575,8 +542,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
updateRequest.scriptedUpsert(true);
updateRequest.upsert(singletonMap("level", "A"));
- UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync,
- highLevelClient()::update, highLevelClient()::updateAsync);
+ UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync);
assertEquals(RestStatus.CREATED, updateResponse.status());
assertEquals("index", updateResponse.getIndex());
assertEquals("type", updateResponse.getType());
@@ -591,8 +557,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
UpdateRequest updateRequest = new UpdateRequest("index", "type", "id");
updateRequest.doc(new IndexRequest().source(Collections.singletonMap("field", "doc"), XContentType.JSON));
updateRequest.upsert(new IndexRequest().source(Collections.singletonMap("field", "upsert"), XContentType.YAML));
- execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync,
- highLevelClient()::update, highLevelClient()::updateAsync);
+ execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync);
});
assertEquals("Update request cannot have different content types for doc [JSON] and upsert [YAML] documents",
exception.getMessage());
@@ -651,8 +616,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
}
}
- BulkResponse bulkResponse = execute(bulkRequest, highLevelClient()::bulk, highLevelClient()::bulkAsync,
- highLevelClient()::bulk, highLevelClient()::bulkAsync);
+ BulkResponse bulkResponse = execute(bulkRequest, highLevelClient()::bulk, highLevelClient()::bulkAsync);
assertEquals(RestStatus.OK, bulkResponse.status());
assertTrue(bulkResponse.getTook().getMillis() > 0);
assertEquals(nbItems, bulkResponse.getItems().length);
@@ -688,10 +652,8 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
}
};
- // Pull the client to a variable to work around https://bugs.eclipse.org/bugs/show_bug.cgi?id=514884
- RestHighLevelClient hlClient = highLevelClient();
-
- try (BulkProcessor processor = BulkProcessor.builder(hlClient::bulkAsync, listener)
+ try (BulkProcessor processor = BulkProcessor.builder(
+ (request, bulkListener) -> highLevelClient().bulkAsync(request, RequestOptions.DEFAULT, bulkListener), listener)
.setConcurrentRequests(0)
.setBulkSize(new ByteSizeValue(5, ByteSizeUnit.GB))
.setBulkActions(nbItems + 1)
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/ESRestHighLevelClientTestCase.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/ESRestHighLevelClientTestCase.java
index 14fe0e01d31..4ad39f54758 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/ESRestHighLevelClientTestCase.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/ESRestHighLevelClientTestCase.java
@@ -19,7 +19,6 @@
package org.elasticsearch.client;
-import org.apache.http.Header;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ingest.PutPipelineRequest;
import org.elasticsearch.action.support.PlainActionFuture;
@@ -80,43 +79,6 @@ public abstract class ESRestHighLevelClientTestCase extends ESRestTestCase {
void execute(Request request, RequestOptions options, ActionListener listener);
}
- /**
- * Executes the provided request using either the sync method or its async variant, both provided as functions
- */
- @Deprecated
- protected static Resp execute(Req request, SyncMethod syncMethod, AsyncMethod asyncMethod,
- SyncMethodWithHeaders syncMethodWithHeaders,
- AsyncMethodWithHeaders asyncMethodWithHeaders) throws IOException {
- switch(randomIntBetween(0, 3)) {
- case 0:
- return syncMethod.execute(request, RequestOptions.DEFAULT);
- case 1:
- PlainActionFuture future = PlainActionFuture.newFuture();
- asyncMethod.execute(request, RequestOptions.DEFAULT, future);
- return future.actionGet();
- case 2:
- return syncMethodWithHeaders.execute(request);
- case 3:
- PlainActionFuture futureWithHeaders = PlainActionFuture.newFuture();
- asyncMethodWithHeaders.execute(request, futureWithHeaders);
- return futureWithHeaders.actionGet();
- default:
- throw new UnsupportedOperationException();
- }
- }
-
- @Deprecated
- @FunctionalInterface
- protected interface SyncMethodWithHeaders {
- Response execute(Request request, Header... headers) throws IOException;
- }
-
- @Deprecated
- @FunctionalInterface
- protected interface AsyncMethodWithHeaders {
- void execute(Request request, ActionListener listener, Header... headers);
- }
-
private static class HighLevelClient extends RestHighLevelClient {
private HighLevelClient(RestClient restClient) {
super(restClient, (client) -> {}, Collections.emptyList());
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java
index 9b54938ede4..82ac161f5af 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java
@@ -117,8 +117,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
boolean response = execute(
request,
highLevelClient().indices()::exists,
- highLevelClient().indices()::existsAsync,
- highLevelClient().indices()::exists,
highLevelClient().indices()::existsAsync
);
assertTrue(response);
@@ -134,8 +132,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
boolean response = execute(
request,
highLevelClient().indices()::exists,
- highLevelClient().indices()::existsAsync,
- highLevelClient().indices()::exists,
highLevelClient().indices()::existsAsync
);
assertFalse(response);
@@ -154,8 +150,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
boolean response = execute(
request,
highLevelClient().indices()::exists,
- highLevelClient().indices()::existsAsync,
- highLevelClient().indices()::exists,
highLevelClient().indices()::existsAsync
);
assertFalse(response);
@@ -173,8 +167,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName);
CreateIndexResponse createIndexResponse =
- execute(createIndexRequest, highLevelClient().indices()::create, highLevelClient().indices()::createAsync,
- highLevelClient().indices()::create, highLevelClient().indices()::createAsync);
+ execute(createIndexRequest, highLevelClient().indices()::create, highLevelClient().indices()::createAsync);
assertTrue(createIndexResponse.isAcknowledged());
assertTrue(indexExists(indexName));
@@ -202,8 +195,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
createIndexRequest.mapping("type_name", mappingBuilder);
CreateIndexResponse createIndexResponse =
- execute(createIndexRequest, highLevelClient().indices()::create, highLevelClient().indices()::createAsync,
- highLevelClient().indices()::create, highLevelClient().indices()::createAsync);
+ execute(createIndexRequest, highLevelClient().indices()::create, highLevelClient().indices()::createAsync);
assertTrue(createIndexResponse.isAcknowledged());
Map getIndexResponse = getAsMap(indexName);
@@ -338,8 +330,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
putMappingRequest.source(mappingBuilder);
PutMappingResponse putMappingResponse =
- execute(putMappingRequest, highLevelClient().indices()::putMapping, highLevelClient().indices()::putMappingAsync,
- highLevelClient().indices()::putMapping, highLevelClient().indices()::putMappingAsync);
+ execute(putMappingRequest, highLevelClient().indices()::putMapping, highLevelClient().indices()::putMappingAsync);
assertTrue(putMappingResponse.isAcknowledged());
Map getIndexResponse = getAsMap(indexName);
@@ -390,8 +381,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(indexName);
DeleteIndexResponse deleteIndexResponse =
- execute(deleteIndexRequest, highLevelClient().indices()::delete, highLevelClient().indices()::deleteAsync,
- highLevelClient().indices()::delete, highLevelClient().indices()::deleteAsync);
+ execute(deleteIndexRequest, highLevelClient().indices()::delete, highLevelClient().indices()::deleteAsync);
assertTrue(deleteIndexResponse.isAcknowledged());
assertFalse(indexExists(indexName));
@@ -404,8 +394,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(nonExistentIndex);
ElasticsearchException exception = expectThrows(ElasticsearchException.class,
- () -> execute(deleteIndexRequest, highLevelClient().indices()::delete, highLevelClient().indices()::deleteAsync,
- highLevelClient().indices()::delete, highLevelClient().indices()::deleteAsync));
+ () -> execute(deleteIndexRequest, highLevelClient().indices()::delete, highLevelClient().indices()::deleteAsync));
assertEquals(RestStatus.NOT_FOUND, exception.status());
}
}
@@ -424,7 +413,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
addAction.routing("routing").searchRouting("search_routing").filter("{\"term\":{\"year\":2016}}");
aliasesAddRequest.addAliasAction(addAction);
IndicesAliasesResponse aliasesAddResponse = execute(aliasesAddRequest, highLevelClient().indices()::updateAliases,
- highLevelClient().indices()::updateAliasesAsync, highLevelClient().indices()::updateAliases,
highLevelClient().indices()::updateAliasesAsync);
assertTrue(aliasesAddResponse.isAcknowledged());
assertThat(aliasExists(alias), equalTo(true));
@@ -443,7 +431,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
AliasActions removeAction = new AliasActions(AliasActions.Type.REMOVE).index(index).alias(alias);
aliasesAddRemoveRequest.addAliasAction(removeAction);
IndicesAliasesResponse aliasesAddRemoveResponse = execute(aliasesAddRemoveRequest, highLevelClient().indices()::updateAliases,
- highLevelClient().indices()::updateAliasesAsync, highLevelClient().indices()::updateAliases,
highLevelClient().indices()::updateAliasesAsync);
assertTrue(aliasesAddRemoveResponse.isAcknowledged());
assertThat(aliasExists(alias), equalTo(false));
@@ -455,7 +442,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
AliasActions removeIndexAction = new AliasActions(AliasActions.Type.REMOVE_INDEX).index(index);
aliasesRemoveIndexRequest.addAliasAction(removeIndexAction);
IndicesAliasesResponse aliasesRemoveIndexResponse = execute(aliasesRemoveIndexRequest, highLevelClient().indices()::updateAliases,
- highLevelClient().indices()::updateAliasesAsync, highLevelClient().indices()::updateAliases,
highLevelClient().indices()::updateAliasesAsync);
assertTrue(aliasesRemoveIndexResponse.isAcknowledged());
assertThat(aliasExists(alias), equalTo(false));
@@ -473,9 +459,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
IndicesAliasesRequest nonExistentIndexRequest = new IndicesAliasesRequest();
nonExistentIndexRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index(nonExistentIndex).alias(alias));
ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> execute(nonExistentIndexRequest,
- highLevelClient().indices()::updateAliases, highLevelClient().indices()::updateAliasesAsync,
- highLevelClient().indices()::updateAliases,
- highLevelClient().indices()::updateAliasesAsync));
+ highLevelClient().indices()::updateAliases, highLevelClient().indices()::updateAliasesAsync));
assertThat(exception.status(), equalTo(RestStatus.NOT_FOUND));
assertThat(exception.getMessage(), equalTo("Elasticsearch exception [type=index_not_found_exception, reason=no such index]"));
assertThat(exception.getMetadata("es.index"), hasItem(nonExistentIndex));
@@ -485,8 +469,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
mixedRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).indices(index).aliases(alias));
mixedRequest.addAliasAction(new AliasActions(AliasActions.Type.REMOVE).indices(nonExistentIndex).alias(alias));
exception = expectThrows(ElasticsearchStatusException.class,
- () -> execute(mixedRequest, highLevelClient().indices()::updateAliases, highLevelClient().indices()::updateAliasesAsync,
- highLevelClient().indices()::updateAliases, highLevelClient().indices()::updateAliasesAsync));
+ () -> execute(mixedRequest, highLevelClient().indices()::updateAliases, highLevelClient().indices()::updateAliasesAsync));
assertThat(exception.status(), equalTo(RestStatus.NOT_FOUND));
assertThat(exception.getMessage(), equalTo("Elasticsearch exception [type=index_not_found_exception, reason=no such index]"));
assertThat(exception.getMetadata("es.index"), hasItem(nonExistentIndex));
@@ -498,7 +481,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
removeIndexRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index(nonExistentIndex).alias(alias));
removeIndexRequest.addAliasAction(new AliasActions(AliasActions.Type.REMOVE_INDEX).indices(nonExistentIndex));
exception = expectThrows(ElasticsearchException.class, () -> execute(removeIndexRequest, highLevelClient().indices()::updateAliases,
- highLevelClient().indices()::updateAliasesAsync, highLevelClient().indices()::updateAliases,
highLevelClient().indices()::updateAliasesAsync));
assertThat(exception.status(), equalTo(RestStatus.NOT_FOUND));
assertThat(exception.getMessage(), equalTo("Elasticsearch exception [type=index_not_found_exception, reason=no such index]"));
@@ -519,7 +501,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
OpenIndexRequest openIndexRequest = new OpenIndexRequest(index);
OpenIndexResponse openIndexResponse = execute(openIndexRequest, highLevelClient().indices()::open,
- highLevelClient().indices()::openAsync, highLevelClient().indices()::open,
highLevelClient().indices()::openAsync);
assertTrue(openIndexResponse.isAcknowledged());
@@ -533,22 +514,19 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
OpenIndexRequest openIndexRequest = new OpenIndexRequest(nonExistentIndex);
ElasticsearchException exception = expectThrows(ElasticsearchException.class,
- () -> execute(openIndexRequest, highLevelClient().indices()::open, highLevelClient().indices()::openAsync,
- highLevelClient().indices()::open, highLevelClient().indices()::openAsync));
+ () -> execute(openIndexRequest, highLevelClient().indices()::open, highLevelClient().indices()::openAsync));
assertEquals(RestStatus.NOT_FOUND, exception.status());
OpenIndexRequest lenientOpenIndexRequest = new OpenIndexRequest(nonExistentIndex);
lenientOpenIndexRequest.indicesOptions(IndicesOptions.lenientExpandOpen());
OpenIndexResponse lenientOpenIndexResponse = execute(lenientOpenIndexRequest, highLevelClient().indices()::open,
- highLevelClient().indices()::openAsync, highLevelClient().indices()::open,
highLevelClient().indices()::openAsync);
assertThat(lenientOpenIndexResponse.isAcknowledged(), equalTo(true));
OpenIndexRequest strictOpenIndexRequest = new OpenIndexRequest(nonExistentIndex);
strictOpenIndexRequest.indicesOptions(IndicesOptions.strictExpandOpen());
ElasticsearchException strictException = expectThrows(ElasticsearchException.class,
- () -> execute(openIndexRequest, highLevelClient().indices()::open, highLevelClient().indices()::openAsync,
- highLevelClient().indices()::open, highLevelClient().indices()::openAsync));
+ () -> execute(openIndexRequest, highLevelClient().indices()::open, highLevelClient().indices()::openAsync));
assertEquals(RestStatus.NOT_FOUND, strictException.status());
}
@@ -560,7 +538,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
CloseIndexRequest closeIndexRequest = new CloseIndexRequest(index);
CloseIndexResponse closeIndexResponse = execute(closeIndexRequest, highLevelClient().indices()::close,
- highLevelClient().indices()::closeAsync, highLevelClient().indices()::close,
highLevelClient().indices()::closeAsync);
assertTrue(closeIndexResponse.isAcknowledged());
@@ -576,8 +553,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
CloseIndexRequest closeIndexRequest = new CloseIndexRequest(nonExistentIndex);
ElasticsearchException exception = expectThrows(ElasticsearchException.class,
- () -> execute(closeIndexRequest, highLevelClient().indices()::close, highLevelClient().indices()::closeAsync,
- highLevelClient().indices()::close, highLevelClient().indices()::closeAsync));
+ () -> execute(closeIndexRequest, highLevelClient().indices()::close, highLevelClient().indices()::closeAsync));
assertEquals(RestStatus.NOT_FOUND, exception.status());
}
@@ -591,8 +567,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
createIndex(index, settings);
RefreshRequest refreshRequest = new RefreshRequest(index);
RefreshResponse refreshResponse =
- execute(refreshRequest, highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync,
- highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync);
+ execute(refreshRequest, highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync);
assertThat(refreshResponse.getTotalShards(), equalTo(1));
assertThat(refreshResponse.getSuccessfulShards(), equalTo(1));
assertThat(refreshResponse.getFailedShards(), equalTo(0));
@@ -603,8 +578,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
assertFalse(indexExists(nonExistentIndex));
RefreshRequest refreshRequest = new RefreshRequest(nonExistentIndex);
ElasticsearchException exception = expectThrows(ElasticsearchException.class,
- () -> execute(refreshRequest, highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync,
- highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync));
+ () -> execute(refreshRequest, highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync));
assertEquals(RestStatus.NOT_FOUND, exception.status());
}
}
@@ -619,8 +593,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
createIndex(index, settings);
FlushRequest flushRequest = new FlushRequest(index);
FlushResponse flushResponse =
- execute(flushRequest, highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync,
- highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync);
+ execute(flushRequest, highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync);
assertThat(flushResponse.getTotalShards(), equalTo(1));
assertThat(flushResponse.getSuccessfulShards(), equalTo(1));
assertThat(flushResponse.getFailedShards(), equalTo(0));
@@ -631,8 +604,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
assertFalse(indexExists(nonExistentIndex));
FlushRequest flushRequest = new FlushRequest(nonExistentIndex);
ElasticsearchException exception = expectThrows(ElasticsearchException.class,
- () -> execute(flushRequest, highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync,
- highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync));
+ () -> execute(flushRequest, highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync));
assertEquals(RestStatus.NOT_FOUND, exception.status());
}
}
@@ -680,8 +652,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
createIndex(index, settings);
ClearIndicesCacheRequest clearCacheRequest = new ClearIndicesCacheRequest(index);
ClearIndicesCacheResponse clearCacheResponse =
- execute(clearCacheRequest, highLevelClient().indices()::clearCache, highLevelClient().indices()::clearCacheAsync,
- highLevelClient().indices()::clearCache, highLevelClient().indices()::clearCacheAsync);
+ execute(clearCacheRequest, highLevelClient().indices()::clearCache, highLevelClient().indices()::clearCacheAsync);
assertThat(clearCacheResponse.getTotalShards(), equalTo(1));
assertThat(clearCacheResponse.getSuccessfulShards(), equalTo(1));
assertThat(clearCacheResponse.getFailedShards(), equalTo(0));
@@ -692,8 +663,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
assertFalse(indexExists(nonExistentIndex));
ClearIndicesCacheRequest clearCacheRequest = new ClearIndicesCacheRequest(nonExistentIndex);
ElasticsearchException exception = expectThrows(ElasticsearchException.class,
- () -> execute(clearCacheRequest, highLevelClient().indices()::clearCache, highLevelClient().indices()::clearCacheAsync,
- highLevelClient().indices()::clearCache, highLevelClient().indices()::clearCacheAsync));
+ () -> execute(clearCacheRequest, highLevelClient().indices()::clearCache,
+ highLevelClient().indices()::clearCacheAsync));
assertEquals(RestStatus.NOT_FOUND, exception.status());
}
}
@@ -708,8 +679,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
createIndex(index, settings);
ForceMergeRequest forceMergeRequest = new ForceMergeRequest(index);
ForceMergeResponse forceMergeResponse =
- execute(forceMergeRequest, highLevelClient().indices()::forceMerge, highLevelClient().indices()::forceMergeAsync,
- highLevelClient().indices()::forceMerge, highLevelClient().indices()::forceMergeAsync);
+ execute(forceMergeRequest, highLevelClient().indices()::forceMerge, highLevelClient().indices()::forceMergeAsync);
assertThat(forceMergeResponse.getTotalShards(), equalTo(1));
assertThat(forceMergeResponse.getSuccessfulShards(), equalTo(1));
assertThat(forceMergeResponse.getFailedShards(), equalTo(0));
@@ -720,30 +690,25 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
assertFalse(indexExists(nonExistentIndex));
ForceMergeRequest forceMergeRequest = new ForceMergeRequest(nonExistentIndex);
ElasticsearchException exception = expectThrows(ElasticsearchException.class,
- () -> execute(forceMergeRequest, highLevelClient().indices()::forceMerge, highLevelClient().indices()::forceMergeAsync,
- highLevelClient().indices()::forceMerge, highLevelClient().indices()::forceMergeAsync));
+ () -> execute(forceMergeRequest, highLevelClient().indices()::forceMerge, highLevelClient().indices()::forceMergeAsync));
assertEquals(RestStatus.NOT_FOUND, exception.status());
}
}
public void testExistsAlias() throws IOException {
GetAliasesRequest getAliasesRequest = new GetAliasesRequest("alias");
- assertFalse(execute(getAliasesRequest, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync,
- highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync));
+ assertFalse(execute(getAliasesRequest, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync));
createIndex("index", Settings.EMPTY);
client().performRequest(HttpPut.METHOD_NAME, "/index/_alias/alias");
- assertTrue(execute(getAliasesRequest, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync,
- highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync));
+ assertTrue(execute(getAliasesRequest, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync));
GetAliasesRequest getAliasesRequest2 = new GetAliasesRequest();
getAliasesRequest2.aliases("alias");
getAliasesRequest2.indices("index");
- assertTrue(execute(getAliasesRequest2, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync,
- highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync));
+ assertTrue(execute(getAliasesRequest2, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync));
getAliasesRequest2.indices("does_not_exist");
- assertFalse(execute(getAliasesRequest2, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync,
- highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync));
+ assertFalse(execute(getAliasesRequest2, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync));
}
@SuppressWarnings("unchecked")
@@ -764,7 +729,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
.build();
resizeRequest.setTargetIndex(new CreateIndexRequest("target").settings(targetSettings).alias(new Alias("alias")));
ResizeResponse resizeResponse = execute(resizeRequest, highLevelClient().indices()::shrink,
- highLevelClient().indices()::shrinkAsync, highLevelClient().indices()::shrink, highLevelClient().indices()::shrinkAsync);
+ highLevelClient().indices()::shrinkAsync);
assertTrue(resizeResponse.isAcknowledged());
assertTrue(resizeResponse.isShardsAcknowledged());
Map getIndexResponse = getAsMap("target");
@@ -786,8 +751,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
resizeRequest.setResizeType(ResizeType.SPLIT);
Settings targetSettings = Settings.builder().put("index.number_of_shards", 4).put("index.number_of_replicas", 0).build();
resizeRequest.setTargetIndex(new CreateIndexRequest("target").settings(targetSettings).alias(new Alias("alias")));
- ResizeResponse resizeResponse = execute(resizeRequest, highLevelClient().indices()::split, highLevelClient().indices()::splitAsync,
- highLevelClient().indices()::split, highLevelClient().indices()::splitAsync);
+ ResizeResponse resizeResponse = execute(resizeRequest, highLevelClient().indices()::split, highLevelClient().indices()::splitAsync);
assertTrue(resizeResponse.isAcknowledged());
assertTrue(resizeResponse.isShardsAcknowledged());
Map getIndexResponse = getAsMap("target");
@@ -806,7 +770,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
{
RolloverResponse rolloverResponse = execute(rolloverRequest, highLevelClient().indices()::rollover,
- highLevelClient().indices()::rolloverAsync, highLevelClient().indices()::rollover,
highLevelClient().indices()::rolloverAsync);
assertFalse(rolloverResponse.isRolledOver());
assertFalse(rolloverResponse.isDryRun());
@@ -826,7 +789,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
rolloverRequest.addMaxIndexAgeCondition(new TimeValue(1));
rolloverRequest.dryRun(true);
RolloverResponse rolloverResponse = execute(rolloverRequest, highLevelClient().indices()::rollover,
- highLevelClient().indices()::rolloverAsync, highLevelClient().indices()::rollover,
highLevelClient().indices()::rolloverAsync);
assertFalse(rolloverResponse.isRolledOver());
assertTrue(rolloverResponse.isDryRun());
@@ -841,7 +803,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
rolloverRequest.dryRun(false);
rolloverRequest.addMaxIndexSizeCondition(new ByteSizeValue(1, ByteSizeUnit.MB));
RolloverResponse rolloverResponse = execute(rolloverRequest, highLevelClient().indices()::rollover,
- highLevelClient().indices()::rolloverAsync, highLevelClient().indices()::rollover,
highLevelClient().indices()::rolloverAsync);
assertTrue(rolloverResponse.isRolledOver());
assertFalse(rolloverResponse.isDryRun());
@@ -1067,7 +1028,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
UpdateSettingsRequest dynamicSettingRequest = new UpdateSettingsRequest();
dynamicSettingRequest.settings(Settings.builder().put(dynamicSettingKey, dynamicSettingValue).build());
UpdateSettingsResponse response = execute(dynamicSettingRequest, highLevelClient().indices()::putSettings,
- highLevelClient().indices()::putSettingsAsync, highLevelClient().indices()::putSettings,
highLevelClient().indices()::putSettingsAsync);
assertTrue(response.isAcknowledged());
@@ -1078,7 +1038,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
UpdateSettingsRequest staticSettingRequest = new UpdateSettingsRequest();
staticSettingRequest.settings(Settings.builder().put(staticSettingKey, staticSettingValue).build());
ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> execute(staticSettingRequest,
- highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync,
highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync));
assertThat(exception.getMessage(),
startsWith("Elasticsearch exception [type=illegal_argument_exception, "
@@ -1089,7 +1048,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
closeIndex(index);
response = execute(staticSettingRequest, highLevelClient().indices()::putSettings,
- highLevelClient().indices()::putSettingsAsync, highLevelClient().indices()::putSettings,
highLevelClient().indices()::putSettingsAsync);
assertTrue(response.isAcknowledged());
openIndex(index);
@@ -1100,7 +1058,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
UpdateSettingsRequest unmodifiableSettingRequest = new UpdateSettingsRequest();
unmodifiableSettingRequest.settings(Settings.builder().put(unmodifiableSettingKey, unmodifiableSettingValue).build());
exception = expectThrows(ElasticsearchException.class, () -> execute(unmodifiableSettingRequest,
- highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync,
highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync));
assertThat(exception.getMessage(), startsWith(
"Elasticsearch exception [type=illegal_argument_exception, "
@@ -1128,14 +1085,12 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
indexUpdateSettingsRequest.settings(Settings.builder().put(setting, value).build());
ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> execute(indexUpdateSettingsRequest,
- highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync,
highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync));
assertEquals(RestStatus.NOT_FOUND, exception.status());
assertThat(exception.getMessage(), equalTo("Elasticsearch exception [type=index_not_found_exception, reason=no such index]"));
createIndex(index, Settings.EMPTY);
exception = expectThrows(ElasticsearchException.class, () -> execute(indexUpdateSettingsRequest,
- highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync,
highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync));
assertThat(exception.status(), equalTo(RestStatus.BAD_REQUEST));
assertThat(exception.getMessage(), equalTo(
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RankEvalIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RankEvalIT.java
index 1e12f3f5e62..a7a452484e0 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RankEvalIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RankEvalIT.java
@@ -82,8 +82,7 @@ public class RankEvalIT extends ESRestHighLevelClientTestCase {
RankEvalSpec spec = new RankEvalSpec(specifications, metric);
RankEvalRequest rankEvalRequest = new RankEvalRequest(spec, new String[] { "index", "index2" });
- RankEvalResponse response = execute(rankEvalRequest, highLevelClient()::rankEval, highLevelClient()::rankEvalAsync,
- highLevelClient()::rankEval, highLevelClient()::rankEvalAsync);
+ RankEvalResponse response = execute(rankEvalRequest, highLevelClient()::rankEval, highLevelClient()::rankEvalAsync);
// the expected Prec@ for the first query is 5/7 and the expected Prec@ for the second is 1/7, divided by 2 to get the average
double expectedPrecision = (1.0 / 7.0 + 5.0 / 7.0) / 2.0;
assertEquals(expectedPrecision, response.getEvaluationResult(), Double.MIN_VALUE);
@@ -117,8 +116,7 @@ public class RankEvalIT extends ESRestHighLevelClientTestCase {
// now try this when test2 is closed
client().performRequest("POST", "index2/_close", Collections.emptyMap());
rankEvalRequest.indicesOptions(IndicesOptions.fromParameters(null, "true", null, SearchRequest.DEFAULT_INDICES_OPTIONS));
- response = execute(rankEvalRequest, highLevelClient()::rankEval, highLevelClient()::rankEvalAsync,
- highLevelClient()::rankEval, highLevelClient()::rankEvalAsync);
+ response = execute(rankEvalRequest, highLevelClient()::rankEval, highLevelClient()::rankEvalAsync);
}
private static List createRelevant(String indexName, String... docs) {
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java
index 9084a547c16..49a84146dc8 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java
@@ -188,12 +188,12 @@ public class RestHighLevelClientTests extends ESTestCase {
{
ActionRequestValidationException actualException = expectThrows(ActionRequestValidationException.class,
- () -> restHighLevelClient.performRequest(request, null, null, null));
+ () -> restHighLevelClient.performRequest(request, null, RequestOptions.DEFAULT, null, null));
assertSame(validationException, actualException);
}
{
TrackingActionListener trackingActionListener = new TrackingActionListener();
- restHighLevelClient.performRequestAsync(request, null, null, trackingActionListener, null);
+ restHighLevelClient.performRequestAsync(request, null, RequestOptions.DEFAULT, null, trackingActionListener, null);
assertSame(validationException, trackingActionListener.exception.get());
}
}
@@ -307,13 +307,13 @@ public class RestHighLevelClientTests extends ESTestCase {
Response mockResponse = new Response(REQUEST_LINE, new HttpHost("localhost", 9200), httpResponse);
when(restClient.performRequest(any(Request.class))).thenReturn(mockResponse);
{
- Integer result = restHighLevelClient.performRequest(mainRequest, requestConverter,
+ Integer result = restHighLevelClient.performRequest(mainRequest, requestConverter, RequestOptions.DEFAULT,
response -> response.getStatusLine().getStatusCode(), Collections.emptySet());
assertEquals(restStatus.getStatus(), result.intValue());
}
{
IOException ioe = expectThrows(IOException.class, () -> restHighLevelClient.performRequest(mainRequest,
- requestConverter, response -> {throw new IllegalStateException();}, Collections.emptySet()));
+ requestConverter, RequestOptions.DEFAULT, response -> {throw new IllegalStateException();}, Collections.emptySet()));
assertEquals("Unable to parse response body for Response{requestLine=GET / http/1.1, host=http://localhost:9200, " +
"response=http/1.1 " + restStatus.getStatus() + " " + restStatus.name() + "}", ioe.getMessage());
}
@@ -328,7 +328,7 @@ public class RestHighLevelClientTests extends ESTestCase {
ResponseException responseException = new ResponseException(mockResponse);
when(restClient.performRequest(any(Request.class))).thenThrow(responseException);
ElasticsearchException elasticsearchException = expectThrows(ElasticsearchException.class,
- () -> restHighLevelClient.performRequest(mainRequest, requestConverter,
+ () -> restHighLevelClient.performRequest(mainRequest, requestConverter, RequestOptions.DEFAULT,
response -> response.getStatusLine().getStatusCode(), Collections.emptySet()));
assertEquals(responseException.getMessage(), elasticsearchException.getMessage());
assertEquals(restStatus, elasticsearchException.status());
@@ -346,7 +346,7 @@ public class RestHighLevelClientTests extends ESTestCase {
ResponseException responseException = new ResponseException(mockResponse);
when(restClient.performRequest(any(Request.class))).thenThrow(responseException);
ElasticsearchException elasticsearchException = expectThrows(ElasticsearchException.class,
- () -> restHighLevelClient.performRequest(mainRequest, requestConverter,
+ () -> restHighLevelClient.performRequest(mainRequest, requestConverter, RequestOptions.DEFAULT,
response -> response.getStatusLine().getStatusCode(), Collections.emptySet()));
assertEquals("Elasticsearch exception [type=exception, reason=test error message]", elasticsearchException.getMessage());
assertEquals(restStatus, elasticsearchException.status());
@@ -363,7 +363,7 @@ public class RestHighLevelClientTests extends ESTestCase {
ResponseException responseException = new ResponseException(mockResponse);
when(restClient.performRequest(any(Request.class))).thenThrow(responseException);
ElasticsearchException elasticsearchException = expectThrows(ElasticsearchException.class,
- () -> restHighLevelClient.performRequest(mainRequest, requestConverter,
+ () -> restHighLevelClient.performRequest(mainRequest, requestConverter, RequestOptions.DEFAULT,
response -> response.getStatusLine().getStatusCode(), Collections.emptySet()));
assertEquals("Unable to parse response body", elasticsearchException.getMessage());
assertEquals(restStatus, elasticsearchException.status());
@@ -381,7 +381,7 @@ public class RestHighLevelClientTests extends ESTestCase {
ResponseException responseException = new ResponseException(mockResponse);
when(restClient.performRequest(any(Request.class))).thenThrow(responseException);
ElasticsearchException elasticsearchException = expectThrows(ElasticsearchException.class,
- () -> restHighLevelClient.performRequest(mainRequest, requestConverter,
+ () -> restHighLevelClient.performRequest(mainRequest, requestConverter, RequestOptions.DEFAULT,
response -> response.getStatusLine().getStatusCode(), Collections.emptySet()));
assertEquals("Unable to parse response body", elasticsearchException.getMessage());
assertEquals(restStatus, elasticsearchException.status());
@@ -397,7 +397,7 @@ public class RestHighLevelClientTests extends ESTestCase {
ResponseException responseException = new ResponseException(mockResponse);
when(restClient.performRequest(any(Request.class))).thenThrow(responseException);
//although we got an exception, we turn it into a successful response because the status code was provided among ignores
- assertEquals(Integer.valueOf(404), restHighLevelClient.performRequest(mainRequest, requestConverter,
+ assertEquals(Integer.valueOf(404), restHighLevelClient.performRequest(mainRequest, requestConverter, RequestOptions.DEFAULT,
response -> response.getStatusLine().getStatusCode(), Collections.singleton(404)));
}
@@ -409,7 +409,7 @@ public class RestHighLevelClientTests extends ESTestCase {
ResponseException responseException = new ResponseException(mockResponse);
when(restClient.performRequest(any(Request.class))).thenThrow(responseException);
ElasticsearchException elasticsearchException = expectThrows(ElasticsearchException.class,
- () -> restHighLevelClient.performRequest(mainRequest, requestConverter,
+ () -> restHighLevelClient.performRequest(mainRequest, requestConverter, RequestOptions.DEFAULT,
response -> {throw new IllegalStateException();}, Collections.singleton(404)));
assertEquals(RestStatus.NOT_FOUND, elasticsearchException.status());
assertSame(responseException, elasticsearchException.getCause());
@@ -426,7 +426,7 @@ public class RestHighLevelClientTests extends ESTestCase {
ResponseException responseException = new ResponseException(mockResponse);
when(restClient.performRequest(any(Request.class))).thenThrow(responseException);
ElasticsearchException elasticsearchException = expectThrows(ElasticsearchException.class,
- () -> restHighLevelClient.performRequest(mainRequest, requestConverter,
+ () -> restHighLevelClient.performRequest(mainRequest, requestConverter, RequestOptions.DEFAULT,
response -> {throw new IllegalStateException();}, Collections.singleton(404)));
assertEquals(RestStatus.NOT_FOUND, elasticsearchException.status());
assertSame(responseException, elasticsearchException.getSuppressed()[0]);
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/SearchIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/SearchIT.java
index 80d09acf281..a87aec7c2cf 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/SearchIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/SearchIT.java
@@ -164,8 +164,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
public void testSearchMatchQuery() throws IOException {
SearchRequest searchRequest = new SearchRequest("index");
searchRequest.source(new SearchSourceBuilder().query(new MatchQueryBuilder("num", 10)));
- SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync,
- highLevelClient()::search, highLevelClient()::searchAsync);
+ SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
assertSearchHeader(searchResponse);
assertNull(searchResponse.getAggregations());
assertNull(searchResponse.getSuggest());
@@ -191,8 +190,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
searchSourceBuilder.aggregation(new TermsAggregationBuilder("agg1", ValueType.STRING).field("type.keyword"));
searchSourceBuilder.size(0);
searchRequest.source(searchSourceBuilder);
- SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync,
- highLevelClient()::search, highLevelClient()::searchAsync);
+ SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
assertSearchHeader(searchResponse);
assertNull(searchResponse.getSuggest());
assertEquals(Collections.emptyMap(), searchResponse.getProfileResults());
@@ -218,8 +216,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
searchRequest.source(searchSourceBuilder);
ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class,
- () -> execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync,
- highLevelClient()::search, highLevelClient()::searchAsync));
+ () -> execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync));
assertEquals(RestStatus.BAD_REQUEST, exception.status());
}
@@ -229,8 +226,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
.addRange("first", 0, 30).addRange("second", 31, 200));
searchSourceBuilder.size(0);
searchRequest.source(searchSourceBuilder);
- SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync,
- highLevelClient()::search, highLevelClient()::searchAsync);
+ SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
assertSearchHeader(searchResponse);
assertNull(searchResponse.getSuggest());
assertEquals(Collections.emptyMap(), searchResponse.getProfileResults());
@@ -261,8 +257,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
searchSourceBuilder.aggregation(agg);
searchSourceBuilder.size(0);
searchRequest.source(searchSourceBuilder);
- SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync,
- highLevelClient()::search, highLevelClient()::searchAsync);
+ SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
assertSearchHeader(searchResponse);
assertNull(searchResponse.getSuggest());
assertEquals(Collections.emptyMap(), searchResponse.getProfileResults());
@@ -313,8 +308,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
searchSourceBuilder.aggregation(new MatrixStatsAggregationBuilder("agg1").fields(Arrays.asList("num", "num2")));
searchSourceBuilder.size(0);
searchRequest.source(searchSourceBuilder);
- SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync,
- highLevelClient()::search, highLevelClient()::searchAsync);
+ SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
assertSearchHeader(searchResponse);
assertNull(searchResponse.getSuggest());
assertEquals(Collections.emptyMap(), searchResponse.getProfileResults());
@@ -403,8 +397,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
SearchRequest searchRequest = new SearchRequest(indexName);
searchRequest.source(searchSourceBuilder);
- SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync,
- highLevelClient()::search, highLevelClient()::searchAsync);
+ SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
assertSearchHeader(searchResponse);
assertNull(searchResponse.getSuggest());
assertEquals(Collections.emptyMap(), searchResponse.getProfileResults());
@@ -444,8 +437,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
searchSourceBuilder.size(0);
searchRequest.source(searchSourceBuilder);
- SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync,
- highLevelClient()::search, highLevelClient()::searchAsync);
+ SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
assertSearchHeader(searchResponse);
assertNull(searchResponse.getAggregations());
assertEquals(Collections.emptyMap(), searchResponse.getProfileResults());
@@ -477,8 +469,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
{
SearchRequest searchRequest = new SearchRequest("test").source(SearchSourceBuilder.searchSource()
.scriptField("result", new Script("null")));
- SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync,
- highLevelClient()::search, highLevelClient()::searchAsync);
+ SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
SearchHit searchHit = searchResponse.getHits().getAt(0);
List values = searchHit.getFields().get("result").getValues();
assertNotNull(values);
@@ -488,8 +479,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
{
SearchRequest searchRequest = new SearchRequest("test").source(SearchSourceBuilder.searchSource()
.scriptField("result", new Script("new HashMap()")));
- SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync,
- highLevelClient()::search, highLevelClient()::searchAsync);
+ SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
SearchHit searchHit = searchResponse.getHits().getAt(0);
List values = searchHit.getFields().get("result").getValues();
assertNotNull(values);
@@ -501,8 +491,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
{
SearchRequest searchRequest = new SearchRequest("test").source(SearchSourceBuilder.searchSource()
.scriptField("result", new Script("new String[]{}")));
- SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync,
- highLevelClient()::search, highLevelClient()::searchAsync);
+ SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
SearchHit searchHit = searchResponse.getHits().getAt(0);
List values = searchHit.getFields().get("result").getValues();
assertNotNull(values);
@@ -524,8 +513,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(35).sort("field", SortOrder.ASC);
SearchRequest searchRequest = new SearchRequest("test").scroll(TimeValue.timeValueMinutes(2)).source(searchSourceBuilder);
- SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync,
- highLevelClient()::search, highLevelClient()::searchAsync);
+ SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
try {
long counter = 0;
@@ -537,7 +525,6 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
}
searchResponse = execute(new SearchScrollRequest(searchResponse.getScrollId()).scroll(TimeValue.timeValueMinutes(2)),
- highLevelClient()::searchScroll, highLevelClient()::searchScrollAsync,
highLevelClient()::searchScroll, highLevelClient()::searchScrollAsync);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(100L));
@@ -547,7 +534,6 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
}
searchResponse = execute(new SearchScrollRequest(searchResponse.getScrollId()).scroll(TimeValue.timeValueMinutes(2)),
- highLevelClient()::searchScroll, highLevelClient()::searchScrollAsync,
highLevelClient()::searchScroll, highLevelClient()::searchScrollAsync);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(100L));
@@ -559,14 +545,12 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
ClearScrollRequest clearScrollRequest = new ClearScrollRequest();
clearScrollRequest.addScrollId(searchResponse.getScrollId());
ClearScrollResponse clearScrollResponse = execute(clearScrollRequest,
- highLevelClient()::clearScroll, highLevelClient()::clearScrollAsync,
highLevelClient()::clearScroll, highLevelClient()::clearScrollAsync);
assertThat(clearScrollResponse.getNumFreed(), greaterThan(0));
assertTrue(clearScrollResponse.isSucceeded());
SearchScrollRequest scrollRequest = new SearchScrollRequest(searchResponse.getScrollId()).scroll(TimeValue.timeValueMinutes(2));
ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> execute(scrollRequest,
- highLevelClient()::searchScroll, highLevelClient()::searchScrollAsync,
highLevelClient()::searchScroll, highLevelClient()::searchScrollAsync));
assertEquals(RestStatus.NOT_FOUND, exception.status());
assertThat(exception.getRootCause(), instanceOf(ElasticsearchException.class));
@@ -588,8 +572,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
multiSearchRequest.add(searchRequest3);
MultiSearchResponse multiSearchResponse =
- execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync,
- highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync);
+ execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync);
assertThat(multiSearchResponse.getTook().millis(), Matchers.greaterThanOrEqualTo(0L));
assertThat(multiSearchResponse.getResponses().length, Matchers.equalTo(3));
@@ -631,8 +614,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
multiSearchRequest.add(searchRequest3);
MultiSearchResponse multiSearchResponse =
- execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync,
- highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync);
+ execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync);
assertThat(multiSearchResponse.getTook().millis(), Matchers.greaterThanOrEqualTo(0L));
assertThat(multiSearchResponse.getResponses().length, Matchers.equalTo(3));
@@ -680,8 +662,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
multiSearchRequest.add(searchRequest3);
MultiSearchResponse multiSearchResponse =
- execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync,
- highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync);
+ execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync);
assertThat(multiSearchResponse.getTook().millis(), Matchers.greaterThanOrEqualTo(0L));
assertThat(multiSearchResponse.getResponses().length, Matchers.equalTo(3));
@@ -744,8 +725,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
multiSearchRequest.add(searchRequest2);
MultiSearchResponse multiSearchResponse =
- execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync,
- highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync);
+ execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync);
assertThat(multiSearchResponse.getTook().millis(), Matchers.greaterThanOrEqualTo(0L));
assertThat(multiSearchResponse.getResponses().length, Matchers.equalTo(2));
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CRUDDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CRUDDocumentationIT.java
index ef92e28a072..4193685f14b 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CRUDDocumentationIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CRUDDocumentationIT.java
@@ -746,7 +746,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
listener = new LatchedActionListener<>(listener, latch);
// tag::bulk-execute-async
- client.bulkAsync(request, listener); // <1>
+ client.bulkAsync(request, RequestOptions.DEFAULT, listener); // <1>
// end::bulk-execute-async
assertTrue(latch.await(30L, TimeUnit.SECONDS));
@@ -995,8 +995,9 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
}
};
- BulkProcessor bulkProcessor =
- BulkProcessor.builder(client::bulkAsync, listener).build(); // <5>
+ BulkProcessor bulkProcessor = BulkProcessor.builder(
+ (request, bulkListener) -> client.bulkAsync(request, RequestOptions.DEFAULT, bulkListener),
+ listener).build(); // <5>
// end::bulk-processor-init
assertNotNull(bulkProcessor);
@@ -1054,7 +1055,8 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
// end::bulk-processor-listener
// tag::bulk-processor-options
- BulkProcessor.Builder builder = BulkProcessor.builder(client::bulkAsync, listener);
+ BulkProcessor.Builder builder = BulkProcessor.builder(
+ (request, bulkListener) -> client.bulkAsync(request, RequestOptions.DEFAULT, bulkListener), listener);
builder.setBulkActions(500); // <1>
builder.setBulkSize(new ByteSizeValue(1L, ByteSizeUnit.MB)); // <2>
builder.setConcurrentRequests(0); // <3>
@@ -1175,7 +1177,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
listener = new LatchedActionListener<>(listener, latch);
// tag::multi-get-execute-async
- client.multiGetAsync(request, listener); // <1>
+ client.multiGetAsync(request, RequestOptions.DEFAULT, listener); // <1>
// end::multi-get-execute-async
assertTrue(latch.await(30L, TimeUnit.SECONDS));
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java
index fffba8e5f3f..7bd6b16cecc 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java
@@ -576,7 +576,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
RestHighLevelClient client = highLevelClient();
{
- CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"));
+ CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"), RequestOptions.DEFAULT);
assertTrue(createIndexResponse.isAcknowledged());
PutMappingRequest request = new PutMappingRequest("twitter");
request.type("tweet");
@@ -589,7 +589,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
" }\n" +
"}", // <1>
XContentType.JSON);
- PutMappingResponse putMappingResponse = client.indices().putMapping(request);
+ PutMappingResponse putMappingResponse = client.indices().putMapping(request, RequestOptions.DEFAULT);
assertTrue(putMappingResponse.isAcknowledged());
}
@@ -633,7 +633,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
final RestHighLevelClient client = highLevelClient();
{
- CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"));
+ CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"), RequestOptions.DEFAULT);
assertTrue(createIndexResponse.isAcknowledged());
PutMappingRequest request = new PutMappingRequest("twitter");
request.type("tweet");
@@ -646,7 +646,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
" }\n" +
"}", // <1>
XContentType.JSON);
- PutMappingResponse putMappingResponse = client.indices().putMapping(request);
+ PutMappingResponse putMappingResponse = client.indices().putMapping(request, RequestOptions.DEFAULT);
assertTrue(putMappingResponse.isAcknowledged());
}
@@ -1733,7 +1733,8 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
RestHighLevelClient client = highLevelClient();
{
- CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index").alias(new Alias("alias")));
+ CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index").alias(new Alias("alias")),
+ RequestOptions.DEFAULT);
assertTrue(createIndexResponse.isAcknowledged());
}
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java
index cf6409bab64..adc0fede1aa 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java
@@ -628,7 +628,7 @@ public class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
scrollListener = new LatchedActionListener<>(scrollListener, latch);
// tag::search-scroll-execute-async
- client.searchScrollAsync(scrollRequest, scrollListener); // <1>
+ client.searchScrollAsync(scrollRequest, RequestOptions.DEFAULT, scrollListener); // <1>
// end::search-scroll-execute-async
assertTrue(latch.await(30L, TimeUnit.SECONDS));
diff --git a/docs/reference/migration/migrate_7_0.asciidoc b/docs/reference/migration/migrate_7_0.asciidoc
index 6f008a275c7..c80b0ae64a3 100644
--- a/docs/reference/migration/migrate_7_0.asciidoc
+++ b/docs/reference/migration/migrate_7_0.asciidoc
@@ -36,6 +36,7 @@ Elasticsearch 6.x in order to be readable by Elasticsearch 7.x.
* <>
* <>
* <>
+* <>
include::migrate_7_0/aggregations.asciidoc[]
include::migrate_7_0/analysis.asciidoc[]
@@ -49,4 +50,5 @@ include::migrate_7_0/api.asciidoc[]
include::migrate_7_0/java.asciidoc[]
include::migrate_7_0/settings.asciidoc[]
include::migrate_7_0/scripting.asciidoc[]
-include::migrate_7_0/snapshotstats.asciidoc[]
\ No newline at end of file
+include::migrate_7_0/snapshotstats.asciidoc[]
+include::migrate_7_0/restclient.asciidoc[]
\ No newline at end of file
diff --git a/docs/reference/migration/migrate_7_0/restclient.asciidoc b/docs/reference/migration/migrate_7_0/restclient.asciidoc
new file mode 100644
index 00000000000..146b0d73386
--- /dev/null
+++ b/docs/reference/migration/migrate_7_0/restclient.asciidoc
@@ -0,0 +1,13 @@
+[[breaking_70_restclient_changes]]
+=== High-level REST client changes
+
+==== API methods accepting `Header` argument have been removed
+
+All API methods accepting headers as a `Header` varargs argument, deprecated
+since 6.4, have been removed in favour of the newly introduced methods that
+accept instead a `RequestOptions` argument. In case you are not specifying any
+header, e.g. `client.index(indexRequest)` becomes
+`client.index(indexRequest, RequestOptions.DEFAULT)`.
+In case you are specifying headers
+e.g. `client.index(indexRequest, new Header("name" "value"))` becomes
+`client.index(indexRequest, RequestOptions.DEFAULT.toBuilder().addHeader("name", "value").build());`
\ No newline at end of file