From 26bd57c83a2aa7e80f7e2d59b1c30f0d94681b78 Mon Sep 17 00:00:00 2001 From: javanna Date: Mon, 4 Jun 2018 14:32:08 +0200 Subject: [PATCH 1/7] Add high-level client methods that accept RequestOptions With #30490 we have introduced a new way to provide request options whenever sending a request using the high-level REST client. Before you could provide headers as the last argument varargs of each API method, now you can provide `RequestOptions` that in the future will allow to provide more options which can be specified per request. This commit deprecates all of the client methods that accept a `Header` varargs argument in favour of new methods that accept `RequestOptions` instead. For some API we don't even go through deprecation given that they were not released since they were added, hence in that case we can just move them to the new method. --- .../elasticsearch/client/ClusterClient.java | 27 + .../elasticsearch/client/IndicesClient.java | 479 +++++++++++++++++- .../elasticsearch/client/IngestClient.java | 37 +- .../client/RestHighLevelClient.java | 321 +++++++++++- .../elasticsearch/client/SnapshotClient.java | 57 +-- .../org/elasticsearch/client/TasksClient.java | 15 +- .../elasticsearch/client/BulkProcessorIT.java | 13 +- .../client/BulkProcessorRetryIT.java | 4 +- .../elasticsearch/client/ClusterClientIT.java | 3 + .../java/org/elasticsearch/client/CrudIT.java | 167 +++--- .../client/ESRestHighLevelClientTestCase.java | 45 +- .../elasticsearch/client/IndicesClientIT.java | 102 +++- .../elasticsearch/client/PingAndInfoIT.java | 4 +- .../org/elasticsearch/client/RankEvalIT.java | 7 +- .../client/RestHighLevelClientTests.java | 26 +- .../org/elasticsearch/client/SearchIT.java | 56 +- .../documentation/CRUDDocumentationIT.java | 102 ++-- .../ClusterClientDocumentationIT.java | 16 +- .../IndicesClientDocumentationIT.java | 155 +++--- .../IngestClientDocumentationIT.java | 13 +- .../MigrationDocumentationIT.java | 21 +- .../MiscellaneousDocumentationIT.java | 5 +- .../documentation/SearchDocumentationIT.java | 73 +-- .../SnapshotClientDocumentationIT.java | 19 +- .../TasksClientDocumentationIT.java | 5 +- ...rossClusterSearchUnavailableClusterIT.java | 30 +- 26 files changed, 1336 insertions(+), 466 deletions(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java index f3c84db79d65f..768d5668282ea 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java @@ -46,6 +46,20 @@ public final class ClusterClient { * See Cluster Update Settings * API on elastic.co */ + public ClusterUpdateSettingsResponse putSettings(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest, RequestOptions options) + throws IOException { + return restHighLevelClient.performRequestAndParseEntity(clusterUpdateSettingsRequest, RequestConverters::clusterPutSettings, + options, ClusterUpdateSettingsResponse::fromXContent, emptySet()); + } + + /** + * Updates cluster wide specific settings using the Cluster Update Settings API + *

+ * See Cluster Update Settings + * API on elastic.co + * @deprecated Prefer {@link #putSettings(ClusterUpdateSettingsRequest, RequestOptions)} + */ + @Deprecated public ClusterUpdateSettingsResponse putSettings(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest, Header... headers) throws IOException { return restHighLevelClient.performRequestAndParseEntity(clusterUpdateSettingsRequest, RequestConverters::clusterPutSettings, @@ -58,6 +72,19 @@ public ClusterUpdateSettingsResponse putSettings(ClusterUpdateSettingsRequest cl * See Cluster Update Settings * API on elastic.co */ + public void putSettingsAsync(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest, RequestOptions options, + ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(clusterUpdateSettingsRequest, RequestConverters::clusterPutSettings, + options, ClusterUpdateSettingsResponse::fromXContent, listener, emptySet()); + } + /** + * Asynchronously updates cluster wide specific settings using the Cluster Update Settings API + *

+ * See Cluster Update Settings + * API on elastic.co + * @deprecated Prefer {@link #putSettingsAsync(ClusterUpdateSettingsRequest, RequestOptions, ActionListener)} + */ + @Deprecated public void putSettingsAsync(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest, ActionListener listener, Header... headers) { restHighLevelClient.performRequestAsyncAndParseEntity(clusterUpdateSettingsRequest, RequestConverters::clusterPutSettings, diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java index b08b045d287c0..afc09292c4601 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java @@ -78,6 +78,19 @@ public final class IndicesClient { * See * Delete Index API on elastic.co */ + public DeleteIndexResponse delete(DeleteIndexRequest deleteIndexRequest, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(deleteIndexRequest, RequestConverters::deleteIndex, options, + DeleteIndexResponse::fromXContent, emptySet()); + } + + /** + * Deletes an index using the Delete Index API + *

+ * See + * Delete Index API on elastic.co + * @deprecated Prefer {@link #delete(DeleteIndexRequest, RequestOptions)} + */ + @Deprecated public DeleteIndexResponse delete(DeleteIndexRequest deleteIndexRequest, Header... headers) throws IOException { return restHighLevelClient.performRequestAndParseEntity(deleteIndexRequest, RequestConverters::deleteIndex, DeleteIndexResponse::fromXContent, emptySet(), headers); @@ -89,6 +102,19 @@ public DeleteIndexResponse delete(DeleteIndexRequest deleteIndexRequest, Header. * See * Delete Index API on elastic.co */ + public void deleteAsync(DeleteIndexRequest deleteIndexRequest, RequestOptions options, ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(deleteIndexRequest, RequestConverters::deleteIndex, options, + DeleteIndexResponse::fromXContent, listener, emptySet()); + } + + /** + * Asynchronously deletes an index using the Delete Index API + *

+ * See + * Delete Index API on elastic.co + * @deprecated Prefer {@link #deleteAsync(DeleteIndexRequest, RequestOptions, ActionListener)} + */ + @Deprecated public void deleteAsync(DeleteIndexRequest deleteIndexRequest, ActionListener listener, Header... headers) { restHighLevelClient.performRequestAsyncAndParseEntity(deleteIndexRequest, RequestConverters::deleteIndex, DeleteIndexResponse::fromXContent, listener, emptySet(), headers); @@ -100,6 +126,19 @@ public void deleteAsync(DeleteIndexRequest deleteIndexRequest, ActionListener * Create Index API on elastic.co */ + public CreateIndexResponse create(CreateIndexRequest createIndexRequest, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(createIndexRequest, RequestConverters::createIndex, options, + CreateIndexResponse::fromXContent, emptySet()); + } + + /** + * Creates an index using the Create Index API + *

+ * See + * Create Index API on elastic.co + * @deprecated Prefer {@link #create(CreateIndexRequest, RequestOptions)} + */ + @Deprecated public CreateIndexResponse create(CreateIndexRequest createIndexRequest, Header... headers) throws IOException { return restHighLevelClient.performRequestAndParseEntity(createIndexRequest, RequestConverters::createIndex, CreateIndexResponse::fromXContent, emptySet(), headers); @@ -111,6 +150,19 @@ public CreateIndexResponse create(CreateIndexRequest createIndexRequest, Header. * See * Create Index API on elastic.co */ + public void createAsync(CreateIndexRequest createIndexRequest, RequestOptions options, ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(createIndexRequest, RequestConverters::createIndex, options, + CreateIndexResponse::fromXContent, listener, emptySet()); + } + + /** + * Asynchronously creates an index using the Create Index API + *

+ * See + * Create Index API on elastic.co + * @deprecated Prefer {@link #createAsync(CreateIndexRequest, RequestOptions, ActionListener)} + */ + @Deprecated public void createAsync(CreateIndexRequest createIndexRequest, ActionListener listener, Header... headers) { restHighLevelClient.performRequestAsyncAndParseEntity(createIndexRequest, RequestConverters::createIndex, CreateIndexResponse::fromXContent, listener, emptySet(), headers); @@ -122,6 +174,19 @@ public void createAsync(CreateIndexRequest createIndexRequest, ActionListener * Put Mapping API on elastic.co */ + public PutMappingResponse putMapping(PutMappingRequest putMappingRequest, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(putMappingRequest, RequestConverters::putMapping, options, + PutMappingResponse::fromXContent, emptySet()); + } + + /** + * Updates the mappings on an index using the Put Mapping API + *

+ * See + * Put Mapping API on elastic.co + * @deprecated Prefer {@link #putMapping(PutMappingRequest, RequestOptions)} + */ + @Deprecated public PutMappingResponse putMapping(PutMappingRequest putMappingRequest, Header... headers) throws IOException { return restHighLevelClient.performRequestAndParseEntity(putMappingRequest, RequestConverters::putMapping, PutMappingResponse::fromXContent, emptySet(), headers); @@ -133,6 +198,19 @@ public PutMappingResponse putMapping(PutMappingRequest putMappingRequest, Header * See * Put Mapping API on elastic.co */ + public void putMappingAsync(PutMappingRequest putMappingRequest, RequestOptions options, ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(putMappingRequest, RequestConverters::putMapping, options, + PutMappingResponse::fromXContent, listener, emptySet()); + } + + /** + * Asynchronously updates the mappings on an index using the Put Mapping API + *

+ * See + * Put Mapping API on elastic.co + * @deprecated Prefer {@link #putMappingAsync(PutMappingRequest, RequestOptions, ActionListener)} + */ + @Deprecated public void putMappingAsync(PutMappingRequest putMappingRequest, ActionListener listener, Header... headers) { restHighLevelClient.performRequestAsyncAndParseEntity(putMappingRequest, RequestConverters::putMapping, @@ -146,6 +224,20 @@ public void putMappingAsync(PutMappingRequest putMappingRequest, ActionListener< * "https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html"> * Index Aliases API on elastic.co */ + public IndicesAliasesResponse updateAliases(IndicesAliasesRequest indicesAliasesRequest, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(indicesAliasesRequest, RequestConverters::updateAliases, options, + IndicesAliasesResponse::fromXContent, emptySet()); + } + + /** + * Updates aliases using the Index Aliases API + *

+ * See + * Index Aliases API on elastic.co + * @deprecated {@link #updateAliases(IndicesAliasesRequest, RequestOptions)} + */ + @Deprecated public IndicesAliasesResponse updateAliases(IndicesAliasesRequest indicesAliasesRequest, Header... headers) throws IOException { return restHighLevelClient.performRequestAndParseEntity(indicesAliasesRequest, RequestConverters::updateAliases, IndicesAliasesResponse::fromXContent, emptySet(), headers); @@ -158,8 +250,23 @@ public IndicesAliasesResponse updateAliases(IndicesAliasesRequest indicesAliases * "https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html"> * Index Aliases API on elastic.co */ + public void updateAliasesAsync(IndicesAliasesRequest indicesAliasesRequest, RequestOptions options, + ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(indicesAliasesRequest, RequestConverters::updateAliases, options, + IndicesAliasesResponse::fromXContent, listener, emptySet()); + } + + /** + * Asynchronously updates aliases using the Index Aliases API + *

+ * See + * Index Aliases API on elastic.co + * @deprecated Prefer {@link #updateAliasesAsync(IndicesAliasesRequest, RequestOptions, ActionListener)} + */ + @Deprecated public void updateAliasesAsync(IndicesAliasesRequest indicesAliasesRequest, ActionListener listener, - Header... headers) { + Header... headers) { restHighLevelClient.performRequestAsyncAndParseEntity(indicesAliasesRequest, RequestConverters::updateAliases, IndicesAliasesResponse::fromXContent, listener, emptySet(), headers); } @@ -170,6 +277,19 @@ public void updateAliasesAsync(IndicesAliasesRequest indicesAliasesRequest, Acti * See * Open Index API on elastic.co */ + public OpenIndexResponse open(OpenIndexRequest openIndexRequest, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(openIndexRequest, RequestConverters::openIndex, options, + OpenIndexResponse::fromXContent, emptySet()); + } + + /** + * Opens an index using the Open Index API + *

+ * See + * Open Index API on elastic.co + * @deprecated Prefer {@link #open(OpenIndexRequest, RequestOptions)} + */ + @Deprecated public OpenIndexResponse open(OpenIndexRequest openIndexRequest, Header... headers) throws IOException { return restHighLevelClient.performRequestAndParseEntity(openIndexRequest, RequestConverters::openIndex, OpenIndexResponse::fromXContent, emptySet(), headers); @@ -181,6 +301,19 @@ public OpenIndexResponse open(OpenIndexRequest openIndexRequest, Header... heade * See * Open Index API on elastic.co */ + public void openAsync(OpenIndexRequest openIndexRequest, RequestOptions options, ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(openIndexRequest, RequestConverters::openIndex, options, + OpenIndexResponse::fromXContent, listener, emptySet()); + } + + /** + * Asynchronously opens an index using the Open Index API + *

+ * See + * Open Index API on elastic.co + * @deprecated Prefer {@link #openAsync(OpenIndexRequest, RequestOptions, ActionListener)} + */ + @Deprecated public void openAsync(OpenIndexRequest openIndexRequest, ActionListener listener, Header... headers) { restHighLevelClient.performRequestAsyncAndParseEntity(openIndexRequest, RequestConverters::openIndex, OpenIndexResponse::fromXContent, listener, emptySet(), headers); @@ -192,6 +325,19 @@ public void openAsync(OpenIndexRequest openIndexRequest, ActionListener * Close Index API on elastic.co */ + public CloseIndexResponse close(CloseIndexRequest closeIndexRequest, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(closeIndexRequest, RequestConverters::closeIndex, options, + CloseIndexResponse::fromXContent, emptySet()); + } + + /** + * Closes an index using the Close Index API + *

+ * See + * Close Index API on elastic.co + * @deprecated Prefer {@link #close(CloseIndexRequest, RequestOptions)} + */ + @Deprecated public CloseIndexResponse close(CloseIndexRequest closeIndexRequest, Header... headers) throws IOException { return restHighLevelClient.performRequestAndParseEntity(closeIndexRequest, RequestConverters::closeIndex, CloseIndexResponse::fromXContent, emptySet(), headers); @@ -203,6 +349,20 @@ public CloseIndexResponse close(CloseIndexRequest closeIndexRequest, Header... h * See * Close Index API on elastic.co */ + public void closeAsync(CloseIndexRequest closeIndexRequest, RequestOptions options, ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(closeIndexRequest, RequestConverters::closeIndex, options, + CloseIndexResponse::fromXContent, listener, emptySet()); + } + + + /** + * Asynchronously closes an index using the Close Index API + *

+ * See + * Close Index API on elastic.co + * @deprecated Prefer {@link #closeAsync(CloseIndexRequest, RequestOptions, ActionListener)} + */ + @Deprecated public void closeAsync(CloseIndexRequest closeIndexRequest, ActionListener listener, Header... headers) { restHighLevelClient.performRequestAsyncAndParseEntity(closeIndexRequest, RequestConverters::closeIndex, CloseIndexResponse::fromXContent, listener, emptySet(), headers); @@ -214,6 +374,19 @@ public void closeAsync(CloseIndexRequest closeIndexRequest, ActionListener * Indices Aliases API on elastic.co */ + public boolean existsAlias(GetAliasesRequest getAliasesRequest, RequestOptions options) throws IOException { + return restHighLevelClient.performRequest(getAliasesRequest, RequestConverters::existsAlias, options, + RestHighLevelClient::convertExistsResponse, emptySet()); + } + + /** + * Checks if one or more aliases exist using the Aliases Exist API + *

+ * See + * Indices Aliases API on elastic.co + * @deprecated Prefer {@link #existsAlias(GetAliasesRequest, RequestOptions)} + */ + @Deprecated public boolean existsAlias(GetAliasesRequest getAliasesRequest, Header... headers) throws IOException { return restHighLevelClient.performRequest(getAliasesRequest, RequestConverters::existsAlias, RestHighLevelClient::convertExistsResponse, emptySet(), headers); @@ -225,6 +398,19 @@ public boolean existsAlias(GetAliasesRequest getAliasesRequest, Header... header * See * Indices Aliases API on elastic.co */ + public void existsAliasAsync(GetAliasesRequest getAliasesRequest, RequestOptions options, ActionListener listener) { + restHighLevelClient.performRequestAsync(getAliasesRequest, RequestConverters::existsAlias, options, + RestHighLevelClient::convertExistsResponse, listener, emptySet()); + } + + /** + * Asynchronously checks if one or more aliases exist using the Aliases Exist API + *

+ * See + * Indices Aliases API on elastic.co + * @deprecated Prefer {@link #existsAliasAsync(GetAliasesRequest, RequestOptions, ActionListener)} + */ + @Deprecated public void existsAliasAsync(GetAliasesRequest getAliasesRequest, ActionListener listener, Header... headers) { restHighLevelClient.performRequestAsync(getAliasesRequest, RequestConverters::existsAlias, RestHighLevelClient::convertExistsResponse, listener, emptySet(), headers); @@ -235,6 +421,18 @@ public void existsAliasAsync(GetAliasesRequest getAliasesRequest, ActionListener *

* See Refresh API on elastic.co */ + public RefreshResponse refresh(RefreshRequest refreshRequest, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(refreshRequest, RequestConverters::refresh, options, + RefreshResponse::fromXContent, emptySet()); + } + + /** + * Refresh one or more indices using the Refresh API + *

+ * See Refresh API on elastic.co + * @deprecated Prefer {@link #refresh(RefreshRequest, RequestOptions)} + */ + @Deprecated public RefreshResponse refresh(RefreshRequest refreshRequest, Header... headers) throws IOException { return restHighLevelClient.performRequestAndParseEntity(refreshRequest, RequestConverters::refresh, RefreshResponse::fromXContent, emptySet(), headers); @@ -245,6 +443,18 @@ public RefreshResponse refresh(RefreshRequest refreshRequest, Header... headers) *

* See Refresh API on elastic.co */ + public void refreshAsync(RefreshRequest refreshRequest, RequestOptions options, ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(refreshRequest, RequestConverters::refresh, options, + RefreshResponse::fromXContent, listener, emptySet()); + } + + /** + * Asynchronously refresh one or more indices using the Refresh API + *

+ * See Refresh API on elastic.co + * @deprecated Prefer {@link #refreshAsync(RefreshRequest, RequestOptions, ActionListener)} + */ + @Deprecated public void refreshAsync(RefreshRequest refreshRequest, ActionListener listener, Header... headers) { restHighLevelClient.performRequestAsyncAndParseEntity(refreshRequest, RequestConverters::refresh, RefreshResponse::fromXContent, listener, emptySet(), headers); @@ -255,6 +465,18 @@ public void refreshAsync(RefreshRequest refreshRequest, ActionListener * See Flush API on elastic.co */ + public FlushResponse flush(FlushRequest flushRequest, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(flushRequest, RequestConverters::flush, options, + FlushResponse::fromXContent, emptySet()); + } + + /** + * Flush one or more indices using the Flush API + *

+ * See Flush API on elastic.co + * @deprecated Prefer {@link #flush(FlushRequest, RequestOptions)} + */ + @Deprecated public FlushResponse flush(FlushRequest flushRequest, Header... headers) throws IOException { return restHighLevelClient.performRequestAndParseEntity(flushRequest, RequestConverters::flush, FlushResponse::fromXContent, emptySet(), headers); @@ -265,6 +487,17 @@ public FlushResponse flush(FlushRequest flushRequest, Header... headers) throws *

* See Flush API on elastic.co */ + public void flushAsync(FlushRequest flushRequest, RequestOptions options, ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(flushRequest, RequestConverters::flush, options, + FlushResponse::fromXContent, listener, emptySet()); + } + + /** + * Asynchronously flush one or more indices using the Flush API + *

+ * See Flush API on elastic.co + * @deprecated Prefer {@link #flushAsync(FlushRequest, RequestOptions, ActionListener)} + */ public void flushAsync(FlushRequest flushRequest, ActionListener listener, Header... headers) { restHighLevelClient.performRequestAsyncAndParseEntity(flushRequest, RequestConverters::flush, FlushResponse::fromXContent, listener, emptySet(), headers); @@ -275,9 +508,9 @@ public void flushAsync(FlushRequest flushRequest, ActionListener * See * Synced flush API on elastic.co */ - public SyncedFlushResponse flushSynced(SyncedFlushRequest syncedFlushRequest, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(syncedFlushRequest, RequestConverters::flushSynced, - SyncedFlushResponse::fromXContent, emptySet(), headers); + public SyncedFlushResponse flushSynced(SyncedFlushRequest syncedFlushRequest, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(syncedFlushRequest, RequestConverters::flushSynced, options, + SyncedFlushResponse::fromXContent, emptySet()); } /** @@ -286,21 +519,21 @@ public SyncedFlushResponse flushSynced(SyncedFlushRequest syncedFlushRequest, He * See * Synced flush API on elastic.co */ - public void flushSyncedAsync(SyncedFlushRequest syncedFlushRequest, ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(syncedFlushRequest, RequestConverters::flushSynced, - SyncedFlushResponse::fromXContent, listener, emptySet(), headers); + public void flushSyncedAsync(SyncedFlushRequest syncedFlushRequest, RequestOptions options, + ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(syncedFlushRequest, RequestConverters::flushSynced, options, + SyncedFlushResponse::fromXContent, listener, emptySet()); } - /** * Retrieve the settings of one or more indices *

* See * Indices Get Settings API on elastic.co */ - public GetSettingsResponse getSettings(GetSettingsRequest getSettingsRequest, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(getSettingsRequest, RequestConverters::getSettings, - GetSettingsResponse::fromXContent, emptySet(), headers); + public GetSettingsResponse getSettings(GetSettingsRequest getSettingsRequest, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(getSettingsRequest, RequestConverters::getSettings, options, + GetSettingsResponse::fromXContent, emptySet()); } /** @@ -309,9 +542,10 @@ public GetSettingsResponse getSettings(GetSettingsRequest getSettingsRequest, He * See * Indices Get Settings API on elastic.co */ - public void getSettingsAsync(GetSettingsRequest getSettingsRequest, ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(getSettingsRequest, RequestConverters::getSettings, - GetSettingsResponse::fromXContent, listener, emptySet(), headers); + public void getSettingsAsync(GetSettingsRequest getSettingsRequest, RequestOptions options, + ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(getSettingsRequest, RequestConverters::getSettings, options, + GetSettingsResponse::fromXContent, listener, emptySet()); } /** @@ -320,6 +554,19 @@ public void getSettingsAsync(GetSettingsRequest getSettingsRequest, ActionListen * See * Force Merge API on elastic.co */ + public ForceMergeResponse forceMerge(ForceMergeRequest forceMergeRequest, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(forceMergeRequest, RequestConverters::forceMerge, options, + ForceMergeResponse::fromXContent, emptySet()); + } + + /** + * Force merge one or more indices using the Force Merge API + *

+ * See + * Force Merge API on elastic.co + * @deprecated Prefer {@link #forceMerge(ForceMergeRequest, RequestOptions)} + */ + @Deprecated public ForceMergeResponse forceMerge(ForceMergeRequest forceMergeRequest, Header... headers) throws IOException { return restHighLevelClient.performRequestAndParseEntity(forceMergeRequest, RequestConverters::forceMerge, ForceMergeResponse::fromXContent, emptySet(), headers); @@ -331,6 +578,19 @@ public ForceMergeResponse forceMerge(ForceMergeRequest forceMergeRequest, Header * See * Force Merge API on elastic.co */ + public void forceMergeAsync(ForceMergeRequest forceMergeRequest, RequestOptions options, ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(forceMergeRequest, RequestConverters::forceMerge, options, + ForceMergeResponse::fromXContent, listener, emptySet()); + } + + /** + * Asynchronously force merge one or more indices using the Force Merge API + *

+ * See + * Force Merge API on elastic.co + * @deprecated Prefer {@link #forceMergeAsync(ForceMergeRequest, RequestOptions, ActionListener)} + */ + @Deprecated public void forceMergeAsync(ForceMergeRequest forceMergeRequest, ActionListener listener, Header... headers) { restHighLevelClient.performRequestAsyncAndParseEntity(forceMergeRequest, RequestConverters::forceMerge, ForceMergeResponse::fromXContent, listener, emptySet(), headers); @@ -342,6 +602,20 @@ public void forceMergeAsync(ForceMergeRequest forceMergeRequest, ActionListener< * See * Clear Cache API on elastic.co */ + public ClearIndicesCacheResponse clearCache(ClearIndicesCacheRequest clearIndicesCacheRequest, + RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(clearIndicesCacheRequest, RequestConverters::clearCache, options, + ClearIndicesCacheResponse::fromXContent, emptySet()); + } + + /** + * Clears the cache of one or more indices using the Clear Cache API + *

+ * See + * Clear Cache API on elastic.co + * @deprecated Prefer {@link #clearCache(ClearIndicesCacheRequest, RequestOptions)} + */ + @Deprecated public ClearIndicesCacheResponse clearCache(ClearIndicesCacheRequest clearIndicesCacheRequest, Header... headers) throws IOException { return restHighLevelClient.performRequestAndParseEntity(clearIndicesCacheRequest, RequestConverters::clearCache, ClearIndicesCacheResponse::fromXContent, emptySet(), headers); @@ -353,6 +627,20 @@ public ClearIndicesCacheResponse clearCache(ClearIndicesCacheRequest clearIndice * See * Clear Cache API on elastic.co */ + public void clearCacheAsync(ClearIndicesCacheRequest clearIndicesCacheRequest, RequestOptions options, + ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(clearIndicesCacheRequest, RequestConverters::clearCache, options, + ClearIndicesCacheResponse::fromXContent, listener, emptySet()); + } + + /** + * Asynchronously clears the cache of one or more indices using the Clear Cache API + *

+ * See + * Clear Cache API on elastic.co + * @deprecated Prefer {@link #clearCacheAsync(ClearIndicesCacheRequest, RequestOptions, ActionListener)} + */ + @Deprecated public void clearCacheAsync(ClearIndicesCacheRequest clearIndicesCacheRequest, ActionListener listener, Header... headers) { restHighLevelClient.performRequestAsyncAndParseEntity(clearIndicesCacheRequest, RequestConverters::clearCache, @@ -365,13 +653,48 @@ public void clearCacheAsync(ClearIndicesCacheRequest clearIndicesCacheRequest, A * See * Indices Exists API on elastic.co */ - public boolean exists(GetIndexRequest request, Header... headers) throws IOException { + public boolean exists(GetIndexRequest request, RequestOptions options) throws IOException { return restHighLevelClient.performRequest( request, RequestConverters::indicesExist, + options, RestHighLevelClient::convertExistsResponse, - Collections.emptySet(), - headers + Collections.emptySet() + ); + } + + /** + * Checks if the index (indices) exists or not. + *

+ * See + * Indices Exists API on elastic.co + * @deprecated Prefer {@link #exists(GetIndexRequest, RequestOptions)} + */ + @Deprecated + public boolean exists(GetIndexRequest request, Header... headers) throws IOException { + return restHighLevelClient.performRequest( + request, + RequestConverters::indicesExist, + RestHighLevelClient::convertExistsResponse, + Collections.emptySet(), + headers + ); + } + + /** + * Asynchronously checks if the index (indices) exists or not. + *

+ * See + * Indices Exists API on elastic.co + */ + public void existsAsync(GetIndexRequest request, RequestOptions options, ActionListener listener) { + restHighLevelClient.performRequestAsync( + request, + RequestConverters::indicesExist, + options, + RestHighLevelClient::convertExistsResponse, + listener, + Collections.emptySet() ); } @@ -380,7 +703,9 @@ public boolean exists(GetIndexRequest request, Header... headers) throws IOExcep *

* See * Indices Exists API on elastic.co + * @deprecated Prefer {@link #existsAsync(GetIndexRequest, RequestOptions, ActionListener)} */ + @Deprecated public void existsAsync(GetIndexRequest request, ActionListener listener, Header... headers) { restHighLevelClient.performRequestAsync( request, @@ -398,6 +723,19 @@ public void existsAsync(GetIndexRequest request, ActionListener listene * See * Shrink Index API on elastic.co */ + public ResizeResponse shrink(ResizeRequest resizeRequest, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(resizeRequest, RequestConverters::shrink, options, + ResizeResponse::fromXContent, emptySet()); + } + + /** + * Shrinks an index using the Shrink Index API + *

+ * See + * Shrink Index API on elastic.co + * @deprecated Prefer {@link #shrink(ResizeRequest, RequestOptions)} + */ + @Deprecated public ResizeResponse shrink(ResizeRequest resizeRequest, Header... headers) throws IOException { return restHighLevelClient.performRequestAndParseEntity(resizeRequest, RequestConverters::shrink, ResizeResponse::fromXContent, emptySet(), headers); @@ -409,6 +747,19 @@ public ResizeResponse shrink(ResizeRequest resizeRequest, Header... headers) thr * See * Shrink Index API on elastic.co */ + public void shrinkAsync(ResizeRequest resizeRequest, RequestOptions options, ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(resizeRequest, RequestConverters::shrink, options, + ResizeResponse::fromXContent, listener, emptySet()); + } + + /** + * Asynchronously shrinks an index using the Shrink index API + *

+ * See + * Shrink Index API on elastic.co + * @deprecated Prefer {@link #shrinkAsync(ResizeRequest, RequestOptions, ActionListener)} + */ + @Deprecated public void shrinkAsync(ResizeRequest resizeRequest, ActionListener listener, Header... headers) { restHighLevelClient.performRequestAsyncAndParseEntity(resizeRequest, RequestConverters::shrink, ResizeResponse::fromXContent, listener, emptySet(), headers); @@ -420,6 +771,19 @@ public void shrinkAsync(ResizeRequest resizeRequest, ActionListener * Split Index API on elastic.co */ + public ResizeResponse split(ResizeRequest resizeRequest, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(resizeRequest, RequestConverters::split, options, + ResizeResponse::fromXContent, emptySet()); + } + + /** + * Splits an index using the Split Index API + *

+ * See + * Split Index API on elastic.co + * @deprecated {@link #split(ResizeRequest, RequestOptions)} + */ + @Deprecated public ResizeResponse split(ResizeRequest resizeRequest, Header... headers) throws IOException { return restHighLevelClient.performRequestAndParseEntity(resizeRequest, RequestConverters::split, ResizeResponse::fromXContent, emptySet(), headers); @@ -431,6 +795,19 @@ public ResizeResponse split(ResizeRequest resizeRequest, Header... headers) thro * See * Split Index API on elastic.co */ + public void splitAsync(ResizeRequest resizeRequest, RequestOptions options, ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(resizeRequest, RequestConverters::split, options, + ResizeResponse::fromXContent, listener, emptySet()); + } + + /** + * Asynchronously splits an index using the Split Index API + *

+ * See + * Split Index API on elastic.co + * @deprecated Prefer {@link #splitAsync(ResizeRequest, RequestOptions, ActionListener)} + */ + @Deprecated public void splitAsync(ResizeRequest resizeRequest, ActionListener listener, Header... headers) { restHighLevelClient.performRequestAsyncAndParseEntity(resizeRequest, RequestConverters::split, ResizeResponse::fromXContent, listener, emptySet(), headers); @@ -442,6 +819,19 @@ public void splitAsync(ResizeRequest resizeRequest, ActionListener * Rollover Index API on elastic.co */ + public RolloverResponse rollover(RolloverRequest rolloverRequest, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(rolloverRequest, RequestConverters::rollover, options, + RolloverResponse::fromXContent, emptySet()); + } + + /** + * Rolls over an index using the Rollover Index API + *

+ * See + * Rollover Index API on elastic.co + * @deprecated Prefer {@link #rollover(RolloverRequest, RequestOptions)} + */ + @Deprecated public RolloverResponse rollover(RolloverRequest rolloverRequest, Header... headers) throws IOException { return restHighLevelClient.performRequestAndParseEntity(rolloverRequest, RequestConverters::rollover, RolloverResponse::fromXContent, emptySet(), headers); @@ -453,6 +843,19 @@ public RolloverResponse rollover(RolloverRequest rolloverRequest, Header... head * See * Rollover Index API on elastic.co */ + public void rolloverAsync(RolloverRequest rolloverRequest, RequestOptions options, ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(rolloverRequest, RequestConverters::rollover, options, + RolloverResponse::fromXContent, listener, emptySet()); + } + + /** + * Asynchronously rolls over an index using the Rollover Index API + *

+ * See + * Rollover Index API on elastic.co + * @deprecated Prefer {@link #rolloverAsync(RolloverRequest, RequestOptions, ActionListener)} + */ + @Deprecated public void rolloverAsync(RolloverRequest rolloverRequest, ActionListener listener, Header... headers) { restHighLevelClient.performRequestAsyncAndParseEntity(rolloverRequest, RequestConverters::rollover, RolloverResponse::fromXContent, listener, emptySet(), headers); @@ -464,6 +867,19 @@ public void rolloverAsync(RolloverRequest rolloverRequest, ActionListener Update Indices Settings * API on elastic.co */ + public UpdateSettingsResponse putSettings(UpdateSettingsRequest updateSettingsRequest, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(updateSettingsRequest, RequestConverters::indexPutSettings, options, + UpdateSettingsResponse::fromXContent, emptySet()); + } + + /** + * Updates specific index level settings using the Update Indices Settings API + *

+ * See Update Indices Settings + * API on elastic.co + * @deprecated Prefer {@link #putSettings(UpdateSettingsRequest, RequestOptions)} + */ + @Deprecated public UpdateSettingsResponse putSettings(UpdateSettingsRequest updateSettingsRequest, Header... headers) throws IOException { return restHighLevelClient.performRequestAndParseEntity(updateSettingsRequest, RequestConverters::indexPutSettings, UpdateSettingsResponse::fromXContent, emptySet(), headers); @@ -475,6 +891,20 @@ public UpdateSettingsResponse putSettings(UpdateSettingsRequest updateSettingsRe * See Update Indices Settings * API on elastic.co */ + public void putSettingsAsync(UpdateSettingsRequest updateSettingsRequest, RequestOptions options, + ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(updateSettingsRequest, RequestConverters::indexPutSettings, options, + 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 #putMappingAsync(PutMappingRequest, RequestOptions, ActionListener)} + */ + @Deprecated public void putSettingsAsync(UpdateSettingsRequest updateSettingsRequest, ActionListener listener, Header... headers) { restHighLevelClient.performRequestAsyncAndParseEntity(updateSettingsRequest, RequestConverters::indexPutSettings, @@ -487,9 +917,10 @@ public void putSettingsAsync(UpdateSettingsRequest updateSettingsRequest, Action * See Index Templates API * on elastic.co */ - public PutIndexTemplateResponse putTemplate(PutIndexTemplateRequest putIndexTemplateRequest, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(putIndexTemplateRequest, RequestConverters::putTemplate, - PutIndexTemplateResponse::fromXContent, emptySet(), headers); + public PutIndexTemplateResponse putTemplate(PutIndexTemplateRequest putIndexTemplateRequest, + RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(putIndexTemplateRequest, RequestConverters::putTemplate, options, + PutIndexTemplateResponse::fromXContent, emptySet()); } /** @@ -498,9 +929,9 @@ public PutIndexTemplateResponse putTemplate(PutIndexTemplateRequest putIndexTemp * See Index Templates API * on elastic.co */ - public void putTemplateAsync(PutIndexTemplateRequest putIndexTemplateRequest, - ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(putIndexTemplateRequest, RequestConverters::putTemplate, - PutIndexTemplateResponse::fromXContent, listener, emptySet(), headers); + public void putTemplateAsync(PutIndexTemplateRequest putIndexTemplateRequest, RequestOptions options, + ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(putIndexTemplateRequest, RequestConverters::putTemplate, options, + PutIndexTemplateResponse::fromXContent, listener, emptySet()); } } diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java index 72b1813f93909..be6d0ff83fb6d 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java @@ -19,7 +19,6 @@ package org.elasticsearch.client; -import org.apache.http.Header; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ingest.DeletePipelineRequest; import org.elasticsearch.action.ingest.GetPipelineRequest; @@ -50,9 +49,9 @@ public final class IngestClient { * See * Put Pipeline API on elastic.co */ - public WritePipelineResponse putPipeline(PutPipelineRequest request, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity( request, RequestConverters::putPipeline, - WritePipelineResponse::fromXContent, emptySet(), headers); + public WritePipelineResponse putPipeline(PutPipelineRequest request, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity( request, RequestConverters::putPipeline, options, + WritePipelineResponse::fromXContent, emptySet()); } /** @@ -61,9 +60,9 @@ public WritePipelineResponse putPipeline(PutPipelineRequest request, Header... h * See * Put Pipeline API on elastic.co */ - public void putPipelineAsync(PutPipelineRequest request, ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::putPipeline, - WritePipelineResponse::fromXContent, listener, emptySet(), headers); + public void putPipelineAsync(PutPipelineRequest request, RequestOptions options, ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::putPipeline, options, + WritePipelineResponse::fromXContent, listener, emptySet()); } /** @@ -72,9 +71,9 @@ public void putPipelineAsync(PutPipelineRequest request, ActionListener Get Pipeline API on elastic.co */ - public GetPipelineResponse getPipeline(GetPipelineRequest request, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity( request, RequestConverters::getPipeline, - GetPipelineResponse::fromXContent, emptySet(), headers); + public GetPipelineResponse getPipeline(GetPipelineRequest request, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity( request, RequestConverters::getPipeline, options, + GetPipelineResponse::fromXContent, emptySet()); } /** @@ -83,9 +82,9 @@ public GetPipelineResponse getPipeline(GetPipelineRequest request, Header... hea * See * Get Pipeline API on elastic.co */ - public void getPipelineAsync(GetPipelineRequest request, ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::getPipeline, - GetPipelineResponse::fromXContent, listener, emptySet(), headers); + public void getPipelineAsync(GetPipelineRequest request, RequestOptions options, ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::getPipeline, options, + GetPipelineResponse::fromXContent, listener, emptySet()); } /** @@ -95,9 +94,9 @@ public void getPipelineAsync(GetPipelineRequest request, ActionListener * Delete Pipeline API on elastic.co */ - public WritePipelineResponse deletePipeline(DeletePipelineRequest request, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity( request, RequestConverters::deletePipeline, - WritePipelineResponse::fromXContent, emptySet(), headers); + public WritePipelineResponse deletePipeline(DeletePipelineRequest request, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity( request, RequestConverters::deletePipeline, options, + WritePipelineResponse::fromXContent, emptySet()); } /** @@ -107,8 +106,8 @@ public WritePipelineResponse deletePipeline(DeletePipelineRequest request, Heade * * Delete Pipeline API on elastic.co */ - public void deletePipelineAsync(DeletePipelineRequest request, ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::deletePipeline, - WritePipelineResponse::fromXContent, listener, emptySet(), headers); + public void deletePipelineAsync(DeletePipelineRequest request, RequestOptions options, ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::deletePipeline, options, + WritePipelineResponse::fromXContent, listener, emptySet()); } } 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 a9587b73c1959..0613cc6f10727 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 @@ -327,6 +327,16 @@ public final void bulkAsync(BulkRequest bulkRequest, ActionListener RequestConverters.ping(), options, RestHighLevelClient::convertExistsResponse, + 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); @@ -335,6 +345,16 @@ public final boolean ping(Header... headers) throws IOException { /** * Get the cluster info otherwise provided when sending an HTTP request to port 9200 */ + public final MainResponse info(RequestOptions options) throws IOException { + return performRequestAndParseEntity(new MainRequest(), (request) -> RequestConverters.info(), options, + 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); @@ -345,6 +365,17 @@ public final MainResponse info(Header... headers) throws IOException { * * See Get API on elastic.co */ + public final GetResponse get(GetRequest getRequest, RequestOptions options) throws IOException { + 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); } @@ -354,6 +385,18 @@ public final GetResponse get(GetRequest getRequest, Header... headers) throws IO * * See Get API on elastic.co */ + public final void getAsync(GetRequest getRequest, RequestOptions options, ActionListener listener) { + performRequestAsyncAndParseEntity(getRequest, RequestConverters::get, options, GetResponse::fromXContent, listener, + 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); @@ -364,6 +407,18 @@ public final void getAsync(GetRequest getRequest, ActionListener li * * See Multi Get API on elastic.co */ + public final MultiGetResponse multiGet(MultiGetRequest multiGetRequest, RequestOptions options) throws IOException { + return performRequestAndParseEntity(multiGetRequest, RequestConverters::multiGet, options, MultiGetResponse::fromXContent, + 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); @@ -374,6 +429,18 @@ public final MultiGetResponse multiGet(MultiGetRequest multiGetRequest, Header.. * * See Multi Get API on elastic.co */ + public final void multiGetAsync(MultiGetRequest multiGetRequest, RequestOptions options, ActionListener listener) { + performRequestAsyncAndParseEntity(multiGetRequest, RequestConverters::multiGet, options, MultiGetResponse::fromXContent, listener, + 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); @@ -384,6 +451,17 @@ public final void multiGetAsync(MultiGetRequest multiGetRequest, ActionListener< * * See Get API on elastic.co */ + public final boolean exists(GetRequest getRequest, RequestOptions options) throws IOException { + 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); } @@ -393,6 +471,18 @@ public final boolean exists(GetRequest getRequest, Header... headers) throws IOE * * See Get API on elastic.co */ + public final void existsAsync(GetRequest getRequest, RequestOptions options, ActionListener listener) { + performRequestAsync(getRequest, RequestConverters::exists, options, RestHighLevelClient::convertExistsResponse, listener, + 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); @@ -403,6 +493,17 @@ public final void existsAsync(GetRequest getRequest, ActionListener lis * * See Index API on elastic.co */ + public final IndexResponse index(IndexRequest indexRequest, RequestOptions options) throws IOException { + 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); } @@ -412,6 +513,18 @@ public final IndexResponse index(IndexRequest indexRequest, Header... headers) t * * See Index API on elastic.co */ + public final void indexAsync(IndexRequest indexRequest, RequestOptions options, ActionListener listener) { + performRequestAsyncAndParseEntity(indexRequest, RequestConverters::index, options, IndexResponse::fromXContent, listener, + 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); @@ -422,6 +535,17 @@ public final void indexAsync(IndexRequest indexRequest, ActionListener * See Update API on elastic.co */ + public final UpdateResponse update(UpdateRequest updateRequest, RequestOptions options) throws IOException { + 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); } @@ -431,6 +555,18 @@ public final UpdateResponse update(UpdateRequest updateRequest, Header... header *

* See Update API on elastic.co */ + public final void updateAsync(UpdateRequest updateRequest, RequestOptions options, ActionListener listener) { + performRequestAsyncAndParseEntity(updateRequest, RequestConverters::update, options, UpdateResponse::fromXContent, listener, + 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); @@ -441,6 +577,18 @@ public final void updateAsync(UpdateRequest updateRequest, ActionListenerDelete API on elastic.co */ + public final DeleteResponse delete(DeleteRequest deleteRequest, RequestOptions options) throws IOException { + return performRequestAndParseEntity(deleteRequest, RequestConverters::delete, options, DeleteResponse::fromXContent, + 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); @@ -451,9 +599,21 @@ public final DeleteResponse delete(DeleteRequest deleteRequest, Header... header * * See Delete API on elastic.co */ + public final void deleteAsync(DeleteRequest deleteRequest, RequestOptions options, ActionListener listener) { + performRequestAsyncAndParseEntity(deleteRequest, RequestConverters::delete, options, DeleteResponse::fromXContent, listener, + 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); + Collections.singleton(404), headers); } /** @@ -461,6 +621,17 @@ public final void deleteAsync(DeleteRequest deleteRequest, ActionListenerSearch API on elastic.co */ + public final SearchResponse search(SearchRequest searchRequest, RequestOptions options) throws IOException { + 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); } @@ -470,6 +641,18 @@ public final SearchResponse search(SearchRequest searchRequest, Header... header * * See Search API on elastic.co */ + public final void searchAsync(SearchRequest searchRequest, RequestOptions options, ActionListener listener) { + performRequestAsyncAndParseEntity(searchRequest, RequestConverters::search, options, SearchResponse::fromXContent, listener, + 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); @@ -481,6 +664,19 @@ public final void searchAsync(SearchRequest searchRequest, ActionListenerMulti search API on * elastic.co */ + public final MultiSearchResponse multiSearch(MultiSearchRequest multiSearchRequest, RequestOptions options) throws IOException { + return performRequestAndParseEntity(multiSearchRequest, RequestConverters::multiSearch, options, MultiSearchResponse::fromXContext, + 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); @@ -492,6 +688,19 @@ public final MultiSearchResponse multiSearch(MultiSearchRequest multiSearchReque * See Multi search API on * elastic.co */ + public final void multiSearchAsync(MultiSearchRequest searchRequest, RequestOptions options, + ActionListener listener) { + performRequestAsyncAndParseEntity(searchRequest, RequestConverters::multiSearch, options, MultiSearchResponse::fromXContext, + 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)} + */ public final void multiSearchAsync(MultiSearchRequest searchRequest, ActionListener listener, Header... headers) { performRequestAsyncAndParseEntity(searchRequest, RequestConverters::multiSearch, MultiSearchResponse::fromXContext, listener, emptySet(), headers); @@ -503,6 +712,19 @@ public final void multiSearchAsync(MultiSearchRequest searchRequest, ActionListe * See Search Scroll * API on elastic.co */ + public final SearchResponse searchScroll(SearchScrollRequest searchScrollRequest, RequestOptions options) throws IOException { + return performRequestAndParseEntity(searchScrollRequest, RequestConverters::searchScroll, options, SearchResponse::fromXContent, + 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); @@ -514,6 +736,20 @@ public final SearchResponse searchScroll(SearchScrollRequest searchScrollRequest * See Search Scroll * API on elastic.co */ + public final void searchScrollAsync(SearchScrollRequest searchScrollRequest, RequestOptions options, + ActionListener listener) { + performRequestAsyncAndParseEntity(searchScrollRequest, RequestConverters::searchScroll, options, SearchResponse::fromXContent, + 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, @@ -526,6 +762,19 @@ public final void searchScrollAsync(SearchScrollRequest searchScrollRequest, * See * Clear Scroll API on elastic.co */ + public final ClearScrollResponse clearScroll(ClearScrollRequest clearScrollRequest, RequestOptions options) throws IOException { + return performRequestAndParseEntity(clearScrollRequest, RequestConverters::clearScroll, options, ClearScrollResponse::fromXContent, + 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); @@ -537,6 +786,20 @@ public final ClearScrollResponse clearScroll(ClearScrollRequest clearScrollReque * See * Clear Scroll API on elastic.co */ + public final void clearScrollAsync(ClearScrollRequest clearScrollRequest, RequestOptions options, + ActionListener listener) { + performRequestAsyncAndParseEntity(clearScrollRequest, RequestConverters::clearScroll, options, ClearScrollResponse::fromXContent, + 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, @@ -550,9 +813,9 @@ public final void clearScrollAsync(ClearScrollRequest clearScrollRequest, * on elastic.co. */ public final SearchTemplateResponse searchTemplate(SearchTemplateRequest searchTemplateRequest, - Header... headers) throws IOException { - return performRequestAndParseEntity(searchTemplateRequest, RequestConverters::searchTemplate, - SearchTemplateResponse::fromXContent, emptySet(), headers); + RequestOptions options) throws IOException { + return performRequestAndParseEntity(searchTemplateRequest, RequestConverters::searchTemplate, options, + SearchTemplateResponse::fromXContent, emptySet()); } /** @@ -561,11 +824,10 @@ public final SearchTemplateResponse searchTemplate(SearchTemplateRequest searchT * See Search Template API * on elastic.co. */ - public final void searchTemplateAsync(SearchTemplateRequest searchTemplateRequest, - ActionListener listener, - Header... headers) { - performRequestAsyncAndParseEntity(searchTemplateRequest, RequestConverters::searchTemplate, - SearchTemplateResponse::fromXContent, listener, emptySet(), headers); + public final void searchTemplateAsync(SearchTemplateRequest searchTemplateRequest, RequestOptions options, + ActionListener listener) { + performRequestAsyncAndParseEntity(searchTemplateRequest, RequestConverters::searchTemplate, options, + SearchTemplateResponse::fromXContent, listener, emptySet()); } @@ -575,6 +837,19 @@ public final void searchTemplateAsync(SearchTemplateRequest searchTemplateReques * See Ranking Evaluation API * on elastic.co */ + public final RankEvalResponse rankEval(RankEvalRequest rankEvalRequest, RequestOptions options) throws IOException { + return performRequestAndParseEntity(rankEvalRequest, RequestConverters::rankEval, options, RankEvalResponse::fromXContent, + 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); @@ -586,6 +861,19 @@ public final RankEvalResponse rankEval(RankEvalRequest rankEvalRequest, Header.. * See Ranking Evaluation API * on elastic.co */ + public final void rankEvalAsync(RankEvalRequest rankEvalRequest, RequestOptions options, ActionListener listener) { + performRequestAsyncAndParseEntity(rankEvalRequest, RequestConverters::rankEval, options, RankEvalResponse::fromXContent, listener, + 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); @@ -598,9 +886,9 @@ public final void rankEvalAsync(RankEvalRequest rankEvalRequest, ActionListener< * on elastic.co. */ public final FieldCapabilitiesResponse fieldCaps(FieldCapabilitiesRequest fieldCapabilitiesRequest, - Header... headers) throws IOException { - return performRequestAndParseEntity(fieldCapabilitiesRequest, RequestConverters::fieldCaps, - FieldCapabilitiesResponse::fromXContent, emptySet(), headers); + RequestOptions options) throws IOException { + return performRequestAndParseEntity(fieldCapabilitiesRequest, RequestConverters::fieldCaps, options, + FieldCapabilitiesResponse::fromXContent, emptySet()); } /** @@ -609,11 +897,10 @@ public final FieldCapabilitiesResponse fieldCaps(FieldCapabilitiesRequest fieldC * See Field Capabilities API * on elastic.co. */ - public final void fieldCapsAsync(FieldCapabilitiesRequest fieldCapabilitiesRequest, - ActionListener listener, - Header... headers) { - performRequestAsyncAndParseEntity(fieldCapabilitiesRequest, RequestConverters::fieldCaps, - FieldCapabilitiesResponse::fromXContent, listener, emptySet(), headers); + public final void fieldCapsAsync(FieldCapabilitiesRequest fieldCapabilitiesRequest, RequestOptions options, + ActionListener listener) { + performRequestAsyncAndParseEntity(fieldCapabilitiesRequest, RequestConverters::fieldCaps, options, + FieldCapabilitiesResponse::fromXContent, listener, emptySet()); } @Deprecated diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/SnapshotClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/SnapshotClient.java index 104bc91271148..ad249ea65e45a 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/SnapshotClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/SnapshotClient.java @@ -19,7 +19,6 @@ package org.elasticsearch.client; -import org.apache.http.Header; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest; import org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryResponse; @@ -53,10 +52,10 @@ public final class SnapshotClient { * See Snapshot and Restore * API on elastic.co */ - public GetRepositoriesResponse getRepositories(GetRepositoriesRequest getRepositoriesRequest, Header... headers) + public GetRepositoriesResponse getRepositories(GetRepositoriesRequest getRepositoriesRequest, RequestOptions options) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(getRepositoriesRequest, RequestConverters::getRepositories, - GetRepositoriesResponse::fromXContent, emptySet(), headers); + return restHighLevelClient.performRequestAndParseEntity(getRepositoriesRequest, RequestConverters::getRepositories, options, + GetRepositoriesResponse::fromXContent, emptySet()); } /** @@ -66,10 +65,10 @@ public GetRepositoriesResponse getRepositories(GetRepositoriesRequest getReposit * See Snapshot and Restore * API on elastic.co */ - public void getRepositoriesAsync(GetRepositoriesRequest getRepositoriesRequest, - ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(getRepositoriesRequest, RequestConverters::getRepositories, - GetRepositoriesResponse::fromXContent, listener, emptySet(), headers); + public void getRepositoriesAsync(GetRepositoriesRequest getRepositoriesRequest, RequestOptions options, + ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(getRepositoriesRequest, RequestConverters::getRepositories, options, + GetRepositoriesResponse::fromXContent, listener, emptySet()); } /** @@ -78,9 +77,9 @@ public void getRepositoriesAsync(GetRepositoriesRequest getRepositoriesRequest, * See Snapshot and Restore * API on elastic.co */ - public PutRepositoryResponse createRepository(PutRepositoryRequest putRepositoryRequest, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(putRepositoryRequest, RequestConverters::createRepository, - PutRepositoryResponse::fromXContent, emptySet(), headers); + public PutRepositoryResponse createRepository(PutRepositoryRequest putRepositoryRequest, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(putRepositoryRequest, RequestConverters::createRepository, options, + PutRepositoryResponse::fromXContent, emptySet()); } /** @@ -89,10 +88,10 @@ public PutRepositoryResponse createRepository(PutRepositoryRequest putRepository * See Snapshot and Restore * API on elastic.co */ - public void createRepositoryAsync(PutRepositoryRequest putRepositoryRequest, - ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(putRepositoryRequest, RequestConverters::createRepository, - PutRepositoryResponse::fromXContent, listener, emptySet(), headers); + public void createRepositoryAsync(PutRepositoryRequest putRepositoryRequest, RequestOptions options, + ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(putRepositoryRequest, RequestConverters::createRepository, options, + PutRepositoryResponse::fromXContent, listener, emptySet()); } /** @@ -101,10 +100,10 @@ public void createRepositoryAsync(PutRepositoryRequest putRepositoryRequest, * See Snapshot and Restore * API on elastic.co */ - public DeleteRepositoryResponse deleteRepository(DeleteRepositoryRequest deleteRepositoryRequest, Header... headers) + public DeleteRepositoryResponse deleteRepository(DeleteRepositoryRequest deleteRepositoryRequest, RequestOptions options) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(deleteRepositoryRequest, RequestConverters::deleteRepository, - DeleteRepositoryResponse::fromXContent, emptySet(), headers); + return restHighLevelClient.performRequestAndParseEntity(deleteRepositoryRequest, RequestConverters::deleteRepository, options, + DeleteRepositoryResponse::fromXContent, emptySet()); } /** @@ -113,10 +112,10 @@ public DeleteRepositoryResponse deleteRepository(DeleteRepositoryRequest deleteR * See Snapshot and Restore * API on elastic.co */ - public void deleteRepositoryAsync(DeleteRepositoryRequest deleteRepositoryRequest, - ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(deleteRepositoryRequest, RequestConverters::deleteRepository, - DeleteRepositoryResponse::fromXContent, listener, emptySet(), headers); + public void deleteRepositoryAsync(DeleteRepositoryRequest deleteRepositoryRequest, RequestOptions options, + ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(deleteRepositoryRequest, RequestConverters::deleteRepository, options, + DeleteRepositoryResponse::fromXContent, listener, emptySet()); } /** @@ -125,10 +124,10 @@ public void deleteRepositoryAsync(DeleteRepositoryRequest deleteRepositoryReques * See Snapshot and Restore * API on elastic.co */ - public VerifyRepositoryResponse verifyRepository(VerifyRepositoryRequest verifyRepositoryRequest, Header... headers) + public VerifyRepositoryResponse verifyRepository(VerifyRepositoryRequest verifyRepositoryRequest, RequestOptions options) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(verifyRepositoryRequest, RequestConverters::verifyRepository, - VerifyRepositoryResponse::fromXContent, emptySet(), headers); + return restHighLevelClient.performRequestAndParseEntity(verifyRepositoryRequest, RequestConverters::verifyRepository, options, + VerifyRepositoryResponse::fromXContent, emptySet()); } /** @@ -137,9 +136,9 @@ public VerifyRepositoryResponse verifyRepository(VerifyRepositoryRequest verifyR * See Snapshot and Restore * API on elastic.co */ - public void verifyRepositoryAsync(VerifyRepositoryRequest verifyRepositoryRequest, - ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(verifyRepositoryRequest, RequestConverters::verifyRepository, - VerifyRepositoryResponse::fromXContent, listener, emptySet(), headers); + public void verifyRepositoryAsync(VerifyRepositoryRequest verifyRepositoryRequest, RequestOptions options, + ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(verifyRepositoryRequest, RequestConverters::verifyRepository, options, + VerifyRepositoryResponse::fromXContent, listener, emptySet()); } } 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 214f1e7884a2a..cf4846537cf9f 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 @@ -19,7 +19,6 @@ package org.elasticsearch.client; -import org.apache.http.Header; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest; import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse; @@ -33,7 +32,7 @@ *

* See Task Management API on elastic.co */ -public class TasksClient { +public final class TasksClient { private final RestHighLevelClient restHighLevelClient; TasksClient(RestHighLevelClient restHighLevelClient) { @@ -46,9 +45,9 @@ public class TasksClient { * See * Task Management API on elastic.co */ - public ListTasksResponse list(ListTasksRequest request, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(request, RequestConverters::listTasks, ListTasksResponse::fromXContent, - emptySet(), headers); + public ListTasksResponse list(ListTasksRequest request, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(request, RequestConverters::listTasks, options, + ListTasksResponse::fromXContent, emptySet()); } /** @@ -57,8 +56,8 @@ public ListTasksResponse list(ListTasksRequest request, Header... headers) throw * See * Task Management API on elastic.co */ - public void listAsync(ListTasksRequest request, ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(request, RequestConverters::listTasks, ListTasksResponse::fromXContent, - listener, emptySet(), headers); + public void listAsync(ListTasksRequest request, RequestOptions options, ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(request, RequestConverters::listTasks, options, + ListTasksResponse::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 9782b1016b421..d41c47177f968 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 @@ -20,8 +20,6 @@ package org.elasticsearch.client; import com.carrotsearch.randomizedtesting.generators.RandomPicks; -import org.apache.http.entity.ContentType; -import org.apache.http.nio.entity.NStringEntity; import org.elasticsearch.action.bulk.BulkItemResponse; import org.elasticsearch.action.bulk.BulkProcessor; import org.elasticsearch.action.bulk.BulkRequest; @@ -39,7 +37,6 @@ import org.elasticsearch.common.xcontent.json.JsonXContent; import java.util.Arrays; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -81,7 +78,7 @@ public void testThatBulkProcessorCountIsCorrect() throws Exception { assertThat(listener.afterCounts.get(), equalTo(1)); assertThat(listener.bulkFailures.size(), equalTo(0)); assertResponseItems(listener.bulkItems, numDocs); - assertMultiGetResponse(highLevelClient().multiGet(multiGetRequest), numDocs); + assertMultiGetResponse(highLevelClient().multiGet(multiGetRequest, RequestOptions.DEFAULT), numDocs); } } @@ -107,7 +104,7 @@ public void testBulkProcessorFlush() throws Exception { assertThat(listener.afterCounts.get(), equalTo(1)); assertThat(listener.bulkFailures.size(), equalTo(0)); assertResponseItems(listener.bulkItems, numDocs); - assertMultiGetResponse(highLevelClient().multiGet(multiGetRequest), numDocs); + assertMultiGetResponse(highLevelClient().multiGet(multiGetRequest, RequestOptions.DEFAULT), numDocs); } } @@ -159,7 +156,7 @@ public void testBulkProcessorConcurrentRequests() throws Exception { assertThat(ids.add(bulkItemResponse.getId()), equalTo(true)); } - assertMultiGetResponse(highLevelClient().multiGet(multiGetRequest), numDocs); + assertMultiGetResponse(highLevelClient().multiGet(multiGetRequest, RequestOptions.DEFAULT), numDocs); } public void testBulkProcessorWaitOnClose() throws Exception { @@ -190,7 +187,7 @@ public void testBulkProcessorWaitOnClose() throws Exception { } assertThat(listener.bulkFailures.size(), equalTo(0)); assertResponseItems(listener.bulkItems, numDocs); - assertMultiGetResponse(highLevelClient().multiGet(multiGetRequest), numDocs); + assertMultiGetResponse(highLevelClient().multiGet(multiGetRequest, RequestOptions.DEFAULT), numDocs); } public void testBulkProcessorConcurrentRequestsReadOnlyIndex() throws Exception { @@ -267,7 +264,7 @@ public void testBulkProcessorConcurrentRequestsReadOnlyIndex() throws Exception } } - assertMultiGetResponse(highLevelClient().multiGet(multiGetRequest), testDocs); + assertMultiGetResponse(highLevelClient().multiGet(multiGetRequest, RequestOptions.DEFAULT), testDocs); } private static MultiGetRequest indexDocs(BulkProcessor processor, int numDocs) 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 597d35a99967b..fe6aa6b1017ee 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 @@ -127,8 +127,8 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure) } } - highLevelClient().indices().refresh(new RefreshRequest()); - int multiGetResponsesCount = highLevelClient().multiGet(multiGetRequest).getResponses().length; + highLevelClient().indices().refresh(new RefreshRequest(), RequestOptions.DEFAULT); + int multiGetResponsesCount = highLevelClient().multiGet(multiGetRequest, RequestOptions.DEFAULT).getResponses().length; if (rejectedExecutionExpected) { assertThat(multiGetResponsesCount, lessThanOrEqualTo(numberOfAsyncOps)); 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 9314bb2e36cea..f1110163b2517 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 @@ -57,6 +57,7 @@ public void testClusterPutSettings() throws IOException { setRequest.persistentSettings(map); ClusterUpdateSettingsResponse setResponse = execute(setRequest, highLevelClient().cluster()::putSettings, + highLevelClient().cluster()::putSettingsAsync, highLevelClient().cluster()::putSettings, highLevelClient().cluster()::putSettingsAsync); assertAcked(setResponse); @@ -79,6 +80,7 @@ public void testClusterPutSettings() throws IOException { 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)); @@ -100,6 +102,7 @@ public void testClusterUpdateSettingNonExistent() { 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 f384e5706b09a..6177dea4a184e 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 @@ -68,12 +68,14 @@ public void testDelete() throws IOException { { // Testing deletion String docId = "id"; - highLevelClient().index(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar"))); + highLevelClient().index( + new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar")), RequestOptions.DEFAULT); DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId); if (randomBoolean()) { deleteRequest.version(1L); } - DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync); + DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync, + highLevelClient()::delete, highLevelClient()::deleteAsync); assertEquals("index", deleteResponse.getIndex()); assertEquals("type", deleteResponse.getType()); assertEquals(docId, deleteResponse.getId()); @@ -83,7 +85,8 @@ public void testDelete() throws IOException { // Testing non existing document String docId = "does_not_exist"; DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId); - DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync); + DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync, + highLevelClient()::delete, highLevelClient()::deleteAsync); assertEquals("index", deleteResponse.getIndex()); assertEquals("type", deleteResponse.getType()); assertEquals(docId, deleteResponse.getId()); @@ -92,10 +95,12 @@ public void testDelete() throws IOException { { // Testing version conflict String docId = "version_conflict"; - highLevelClient().index(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar"))); + highLevelClient().index( + 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)); + () -> execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync, + 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()); @@ -104,10 +109,12 @@ public void testDelete() throws IOException { { // Testing version type String docId = "version_type"; - highLevelClient().index(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar")) + highLevelClient().index( + new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar"), RequestOptions.DEFAULT) .versionType(VersionType.EXTERNAL).version(12)); DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId).versionType(VersionType.EXTERNAL).version(13); - DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync); + DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync, + highLevelClient()::delete, highLevelClient()::deleteAsync); assertEquals("index", deleteResponse.getIndex()); assertEquals("type", deleteResponse.getType()); assertEquals(docId, deleteResponse.getId()); @@ -116,11 +123,13 @@ public void testDelete() throws IOException { { // Testing version type with a wrong version String docId = "wrong_version"; - highLevelClient().index(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar")) + highLevelClient().index( + new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar"), RequestOptions.DEFAULT) .versionType(VersionType.EXTERNAL).version(12)); ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> { DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId).versionType(VersionType.EXTERNAL).version(10); - execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync); + execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync, + highLevelClient()::delete, highLevelClient()::deleteAsync); }); assertEquals(RestStatus.CONFLICT, exception.status()); assertEquals("Elasticsearch exception [type=version_conflict_engine_exception, reason=[type][" + @@ -130,9 +139,11 @@ public void testDelete() throws IOException { { // Testing routing String docId = "routing"; - highLevelClient().index(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar")).routing("foo")); + 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); + DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync, + highLevelClient()::delete, highLevelClient()::deleteAsync); assertEquals("index", deleteResponse.getIndex()); assertEquals("type", deleteResponse.getType()); assertEquals(docId, deleteResponse.getId()); @@ -143,23 +154,27 @@ public void testDelete() throws IOException { public void testExists() throws IOException { { GetRequest getRequest = new GetRequest("index", "type", "id"); - assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync)); + assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync, + highLevelClient()::exists, highLevelClient()::existsAsync)); } IndexRequest index = new IndexRequest("index", "type", "id"); index.source("{\"field1\":\"value1\",\"field2\":\"value2\"}", XContentType.JSON); index.setRefreshPolicy(RefreshPolicy.IMMEDIATE); - highLevelClient().index(index); + highLevelClient().index(index, RequestOptions.DEFAULT); { GetRequest getRequest = new GetRequest("index", "type", "id"); - assertTrue(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync)); + assertTrue(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync, + highLevelClient()::exists, highLevelClient()::existsAsync)); } { GetRequest getRequest = new GetRequest("index", "type", "does_not_exist"); - assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync)); + assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync, + highLevelClient()::exists, highLevelClient()::existsAsync)); } { GetRequest getRequest = new GetRequest("index", "type", "does_not_exist").version(1); - assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync)); + assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync, + highLevelClient()::exists, highLevelClient()::existsAsync)); } } @@ -167,7 +182,8 @@ public void testGet() throws IOException { { GetRequest getRequest = new GetRequest("index", "type", "id"); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync)); + () -> execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync, + 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)); @@ -176,11 +192,12 @@ public void testGet() throws IOException { String document = "{\"field1\":\"value1\",\"field2\":\"value2\"}"; index.source(document, XContentType.JSON); index.setRefreshPolicy(RefreshPolicy.IMMEDIATE); - highLevelClient().index(index); + highLevelClient().index(index, RequestOptions.DEFAULT); { GetRequest getRequest = new GetRequest("index", "type", "id").version(2); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync)); + () -> execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync, + 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()); @@ -191,7 +208,8 @@ public void testGet() throws IOException { if (randomBoolean()) { getRequest.version(1L); } - GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync); + GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync, + highLevelClient()::get, highLevelClient()::getAsync); assertEquals("index", getResponse.getIndex()); assertEquals("type", getResponse.getType()); assertEquals("id", getResponse.getId()); @@ -202,7 +220,8 @@ public void testGet() throws IOException { } { GetRequest getRequest = new GetRequest("index", "type", "does_not_exist"); - GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync); + GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync, + highLevelClient()::get, highLevelClient()::getAsync); assertEquals("index", getResponse.getIndex()); assertEquals("type", getResponse.getType()); assertEquals("does_not_exist", getResponse.getId()); @@ -214,7 +233,8 @@ public void testGet() throws IOException { { 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); + GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync, + highLevelClient()::get, highLevelClient()::getAsync); assertEquals("index", getResponse.getIndex()); assertEquals("type", getResponse.getType()); assertEquals("id", getResponse.getId()); @@ -230,7 +250,8 @@ public void testGet() throws IOException { } else { getRequest.fetchSourceContext(new FetchSourceContext(true, Strings.EMPTY_ARRAY, new String[]{"field2"})); } - GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync); + GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync, + highLevelClient()::get, highLevelClient()::getAsync); assertEquals("index", getResponse.getIndex()); assertEquals("type", getResponse.getType()); assertEquals("id", getResponse.getId()); @@ -248,7 +269,8 @@ public void testMultiGet() throws IOException { MultiGetRequest multiGetRequest = new MultiGetRequest(); multiGetRequest.add("index", "type", "id1"); multiGetRequest.add("index", "type", "id2"); - MultiGetResponse response = execute(multiGetRequest, highLevelClient()::multiGet, highLevelClient()::multiGetAsync); + MultiGetResponse response = execute(multiGetRequest, highLevelClient()::multiGet, highLevelClient()::multiGetAsync, + highLevelClient()::multiGet, highLevelClient()::multiGetAsync); assertEquals(2, response.getResponses().length); assertTrue(response.getResponses()[0].isFailed()); @@ -275,12 +297,13 @@ public void testMultiGet() throws IOException { index = new IndexRequest("index", "type", "id2"); index.source("{\"field\":\"value2\"}", XContentType.JSON); bulk.add(index); - highLevelClient().bulk(bulk); + highLevelClient().bulk(bulk, RequestOptions.DEFAULT); { MultiGetRequest multiGetRequest = new MultiGetRequest(); multiGetRequest.add("index", "type", "id1"); multiGetRequest.add("index", "type", "id2"); - MultiGetResponse response = execute(multiGetRequest, highLevelClient()::multiGet, highLevelClient()::multiGetAsync); + MultiGetResponse response = execute(multiGetRequest, highLevelClient()::multiGet, highLevelClient()::multiGetAsync, + highLevelClient()::multiGet, highLevelClient()::multiGetAsync); assertEquals(2, response.getResponses().length); assertFalse(response.getResponses()[0].isFailed()); @@ -305,7 +328,8 @@ public void testIndex() throws IOException { 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); + IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync, + highLevelClient()::index, highLevelClient()::indexAsync); assertEquals(RestStatus.CREATED, indexResponse.status()); assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult()); assertEquals("index", indexResponse.getIndex()); @@ -326,7 +350,8 @@ public void testIndex() throws IOException { 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); + IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync, + highLevelClient()::index, highLevelClient()::indexAsync); assertEquals(RestStatus.CREATED, indexResponse.status()); assertEquals("index", indexResponse.getIndex()); assertEquals("type", indexResponse.getType()); @@ -336,7 +361,8 @@ public void testIndex() throws IOException { indexRequest = new IndexRequest("index", "type", "id"); indexRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("version", 2).endObject()); - indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync); + indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync, + highLevelClient()::index, highLevelClient()::indexAsync); assertEquals(RestStatus.OK, indexResponse.status()); assertEquals("index", indexResponse.getIndex()); assertEquals("type", indexResponse.getType()); @@ -348,7 +374,8 @@ public void testIndex() throws IOException { wrongRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("field", "test").endObject()); wrongRequest.version(5L); - execute(wrongRequest, highLevelClient()::index, highLevelClient()::indexAsync); + execute(wrongRequest, highLevelClient()::index, highLevelClient()::indexAsync, + highLevelClient()::index, highLevelClient()::indexAsync); }); assertEquals(RestStatus.CONFLICT, exception.status()); assertEquals("Elasticsearch exception [type=version_conflict_engine_exception, reason=[type][id]: " + @@ -361,7 +388,8 @@ public void testIndex() throws IOException { indexRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("field", "test").endObject()); indexRequest.setPipeline("missing"); - execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync); + execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync, + highLevelClient()::index, highLevelClient()::indexAsync); }); assertEquals(RestStatus.BAD_REQUEST, exception.status()); @@ -374,7 +402,8 @@ public void testIndex() throws IOException { indexRequest.version(12L); indexRequest.versionType(VersionType.EXTERNAL); - IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync); + IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync, + highLevelClient()::index, highLevelClient()::indexAsync); assertEquals(RestStatus.CREATED, indexResponse.status()); assertEquals("index", indexResponse.getIndex()); assertEquals("type", indexResponse.getType()); @@ -386,14 +415,16 @@ public void testIndex() throws IOException { indexRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("field", "test").endObject()); indexRequest.opType(DocWriteRequest.OpType.CREATE); - IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync); + IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync, + 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); + execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync, + highLevelClient()::index, highLevelClient()::indexAsync); }); assertEquals(RestStatus.CONFLICT, exception.status()); @@ -408,7 +439,8 @@ public void testUpdate() throws IOException { updateRequest.doc(singletonMap("field", "value"), randomFrom(XContentType.values())); ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> - execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync)); + execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync, + 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()); @@ -416,7 +448,7 @@ public void testUpdate() throws IOException { { IndexRequest indexRequest = new IndexRequest("index", "type", "id"); indexRequest.source(singletonMap("field", "value")); - IndexResponse indexResponse = highLevelClient().index(indexRequest); + IndexResponse indexResponse = highLevelClient().index(indexRequest, RequestOptions.DEFAULT); assertEquals(RestStatus.CREATED, indexResponse.status()); UpdateRequest updateRequest = new UpdateRequest("index", "type", "id"); @@ -431,7 +463,8 @@ public void testUpdate() throws IOException { updateRequestConflict.version(indexResponse.getVersion()); ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> - execute(updateRequestConflict, highLevelClient()::update, highLevelClient()::updateAsync)); + execute(updateRequestConflict, highLevelClient()::update, highLevelClient()::updateAsync, + 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()); @@ -439,7 +472,7 @@ public void testUpdate() throws IOException { { IndexRequest indexRequest = new IndexRequest("index", "type", "with_script"); indexRequest.source(singletonMap("counter", 12)); - IndexResponse indexResponse = highLevelClient().index(indexRequest); + IndexResponse indexResponse = highLevelClient().index(indexRequest, RequestOptions.DEFAULT); assertEquals(RestStatus.CREATED, indexResponse.status()); UpdateRequest updateRequest = new UpdateRequest("index", "type", "with_script"); @@ -447,7 +480,8 @@ public void testUpdate() throws IOException { updateRequest.script(script); updateRequest.fetchSource(true); - UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync); + UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync, + highLevelClient()::update, highLevelClient()::updateAsync); assertEquals(RestStatus.OK, updateResponse.status()); assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult()); assertEquals(2L, updateResponse.getVersion()); @@ -459,7 +493,7 @@ public void testUpdate() throws IOException { indexRequest.source("field_1", "one", "field_3", "three"); indexRequest.version(12L); indexRequest.versionType(VersionType.EXTERNAL); - IndexResponse indexResponse = highLevelClient().index(indexRequest); + IndexResponse indexResponse = highLevelClient().index(indexRequest, RequestOptions.DEFAULT); assertEquals(RestStatus.CREATED, indexResponse.status()); assertEquals(12L, indexResponse.getVersion()); @@ -467,7 +501,8 @@ public void testUpdate() throws IOException { updateRequest.doc(singletonMap("field_2", "two"), randomFrom(XContentType.values())); updateRequest.fetchSource("field_*", "field_3"); - UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync); + UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync, + highLevelClient()::update, highLevelClient()::updateAsync); assertEquals(RestStatus.OK, updateResponse.status()); assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult()); assertEquals(13L, updateResponse.getVersion()); @@ -481,14 +516,15 @@ public void testUpdate() throws IOException { { IndexRequest indexRequest = new IndexRequest("index", "type", "noop"); indexRequest.source("field", "value"); - IndexResponse indexResponse = highLevelClient().index(indexRequest); + IndexResponse indexResponse = highLevelClient().index(indexRequest, RequestOptions.DEFAULT); assertEquals(RestStatus.CREATED, indexResponse.status()); assertEquals(1L, indexResponse.getVersion()); UpdateRequest updateRequest = new UpdateRequest("index", "type", "noop"); updateRequest.doc(singletonMap("field", "value"), randomFrom(XContentType.values())); - UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync); + UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync, + highLevelClient()::update, highLevelClient()::updateAsync); assertEquals(RestStatus.OK, updateResponse.status()); assertEquals(DocWriteResponse.Result.NOOP, updateResponse.getResult()); assertEquals(1L, updateResponse.getVersion()); @@ -506,7 +542,8 @@ public void testUpdate() throws IOException { updateRequest.doc(singletonMap("doc_status", "updated")); updateRequest.fetchSource(true); - UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync); + UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync, + highLevelClient()::update, highLevelClient()::updateAsync); assertEquals(RestStatus.CREATED, updateResponse.status()); assertEquals("index", updateResponse.getIndex()); assertEquals("type", updateResponse.getType()); @@ -521,7 +558,8 @@ public void testUpdate() throws IOException { updateRequest.fetchSource(true); updateRequest.docAsUpsert(true); - UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync); + UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync, + highLevelClient()::update, highLevelClient()::updateAsync); assertEquals(RestStatus.CREATED, updateResponse.status()); assertEquals("index", updateResponse.getIndex()); assertEquals("type", updateResponse.getType()); @@ -537,7 +575,8 @@ public void testUpdate() throws IOException { updateRequest.scriptedUpsert(true); updateRequest.upsert(singletonMap("level", "A")); - UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync); + UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync, + highLevelClient()::update, highLevelClient()::updateAsync); assertEquals(RestStatus.CREATED, updateResponse.status()); assertEquals("index", updateResponse.getIndex()); assertEquals("type", updateResponse.getType()); @@ -552,7 +591,8 @@ public void testUpdate() throws IOException { 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); + execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync, + highLevelClient()::update, highLevelClient()::updateAsync); }); assertEquals("Update request cannot have different content types for doc [JSON] and upsert [YAML] documents", exception.getMessage()); @@ -575,7 +615,8 @@ public void testBulk() throws IOException { if (opType == DocWriteRequest.OpType.DELETE) { if (erroneous == false) { assertEquals(RestStatus.CREATED, - highLevelClient().index(new IndexRequest("index", "test", id).source("field", -1)).status()); + highLevelClient().index( + new IndexRequest("index", "test", id).source("field", -1), RequestOptions.DEFAULT).status()); } DeleteRequest deleteRequest = new DeleteRequest("index", "test", id); bulkRequest.add(deleteRequest); @@ -593,7 +634,7 @@ public void testBulk() throws IOException { } else if (opType == DocWriteRequest.OpType.CREATE) { IndexRequest createRequest = new IndexRequest("index", "test", id).source(source, xContentType).create(true); if (erroneous) { - assertEquals(RestStatus.CREATED, highLevelClient().index(createRequest).status()); + assertEquals(RestStatus.CREATED, highLevelClient().index(createRequest, RequestOptions.DEFAULT).status()); } bulkRequest.add(createRequest); @@ -602,14 +643,16 @@ public void testBulk() throws IOException { .doc(new IndexRequest().source(source, xContentType)); if (erroneous == false) { assertEquals(RestStatus.CREATED, - highLevelClient().index(new IndexRequest("index", "test", id).source("field", -1)).status()); + highLevelClient().index( + new IndexRequest("index", "test", id).source("field", -1), RequestOptions.DEFAULT).status()); } bulkRequest.add(updateRequest); } } } - BulkResponse bulkResponse = execute(bulkRequest, highLevelClient()::bulk, highLevelClient()::bulkAsync); + BulkResponse bulkResponse = execute(bulkRequest, highLevelClient()::bulk, highLevelClient()::bulkAsync, + highLevelClient()::bulk, highLevelClient()::bulkAsync); assertEquals(RestStatus.OK, bulkResponse.status()); assertTrue(bulkResponse.getTook().getMillis() > 0); assertEquals(nbItems, bulkResponse.getItems().length); @@ -662,7 +705,8 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure) if (opType == DocWriteRequest.OpType.DELETE) { if (erroneous == false) { assertEquals(RestStatus.CREATED, - highLevelClient().index(new IndexRequest("index", "test", id).source("field", -1)).status()); + highLevelClient().index( + new IndexRequest("index", "test", id).source("field", -1), RequestOptions.DEFAULT).status()); } DeleteRequest deleteRequest = new DeleteRequest("index", "test", id); processor.add(deleteRequest); @@ -678,7 +722,7 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure) } else if (opType == DocWriteRequest.OpType.CREATE) { IndexRequest createRequest = new IndexRequest("index", "test", id).source(xContentType, "id", i).create(true); if (erroneous) { - assertEquals(RestStatus.CREATED, highLevelClient().index(createRequest).status()); + assertEquals(RestStatus.CREATED, highLevelClient().index(createRequest, RequestOptions.DEFAULT).status()); } processor.add(createRequest); @@ -687,7 +731,8 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure) .doc(new IndexRequest().source(xContentType, "id", i)); if (erroneous == false) { assertEquals(RestStatus.CREATED, - highLevelClient().index(new IndexRequest("index", "test", id).source("field", -1)).status()); + highLevelClient().index( + new IndexRequest("index", "test", id).source("field", -1), RequestOptions.DEFAULT).status()); } processor.add(updateRequest); } @@ -739,14 +784,14 @@ public void testUrlEncode() throws IOException { { IndexRequest indexRequest = new IndexRequest(indexPattern, "type", "id#1"); indexRequest.source("field", "value"); - IndexResponse indexResponse = highLevelClient().index(indexRequest); + IndexResponse indexResponse = highLevelClient().index(indexRequest, RequestOptions.DEFAULT); assertEquals(expectedIndex, indexResponse.getIndex()); assertEquals("type", indexResponse.getType()); assertEquals("id#1", indexResponse.getId()); } { GetRequest getRequest = new GetRequest(indexPattern, "type", "id#1"); - GetResponse getResponse = highLevelClient().get(getRequest); + GetResponse getResponse = highLevelClient().get(getRequest, RequestOptions.DEFAULT); assertTrue(getResponse.isExists()); assertEquals(expectedIndex, getResponse.getIndex()); assertEquals("type", getResponse.getType()); @@ -757,21 +802,21 @@ public void testUrlEncode() throws IOException { { IndexRequest indexRequest = new IndexRequest("index", "type", docId); indexRequest.source("field", "value"); - IndexResponse indexResponse = highLevelClient().index(indexRequest); + IndexResponse indexResponse = highLevelClient().index(indexRequest, RequestOptions.DEFAULT); assertEquals("index", indexResponse.getIndex()); assertEquals("type", indexResponse.getType()); assertEquals(docId, indexResponse.getId()); } { GetRequest getRequest = new GetRequest("index", "type", docId); - GetResponse getResponse = highLevelClient().get(getRequest); + GetResponse getResponse = highLevelClient().get(getRequest, RequestOptions.DEFAULT); assertTrue(getResponse.isExists()); assertEquals("index", getResponse.getIndex()); assertEquals("type", getResponse.getType()); assertEquals(docId, getResponse.getId()); } - assertTrue(highLevelClient().indices().exists(new GetIndexRequest().indices(indexPattern, "index"))); + assertTrue(highLevelClient().indices().exists(new GetIndexRequest().indices(indexPattern, "index"), RequestOptions.DEFAULT)); } public void testParamsEncode() throws IOException { @@ -781,14 +826,14 @@ public void testParamsEncode() throws IOException { IndexRequest indexRequest = new IndexRequest("index", "type", "id"); indexRequest.source("field", "value"); indexRequest.routing(routing); - IndexResponse indexResponse = highLevelClient().index(indexRequest); + IndexResponse indexResponse = highLevelClient().index(indexRequest, RequestOptions.DEFAULT); assertEquals("index", indexResponse.getIndex()); assertEquals("type", indexResponse.getType()); assertEquals("id", indexResponse.getId()); } { GetRequest getRequest = new GetRequest("index", "type", "id").routing(routing); - GetResponse getResponse = highLevelClient().get(getRequest); + GetResponse getResponse = highLevelClient().get(getRequest, RequestOptions.DEFAULT); assertTrue(getResponse.isExists()); assertEquals("index", getResponse.getIndex()); assertEquals("type", getResponse.getType()); 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 f7a934405c2ae..14fe0e01d31f9 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 @@ -60,23 +60,60 @@ protected static RestHighLevelClient highLevelClient() { * Executes the provided request using either the sync method or its async variant, both provided as functions */ protected static Resp execute(Req request, SyncMethod syncMethod, - AsyncMethod asyncMethod, Header... headers) throws IOException { + AsyncMethod asyncMethod) throws IOException { if (randomBoolean()) { - return syncMethod.execute(request, headers); + return syncMethod.execute(request, RequestOptions.DEFAULT); } else { PlainActionFuture future = PlainActionFuture.newFuture(); - asyncMethod.execute(request, future, headers); + asyncMethod.execute(request, RequestOptions.DEFAULT, future); return future.actionGet(); } } @FunctionalInterface protected interface SyncMethod { - Response execute(Request request, Header... headers) throws IOException; + Response execute(Request request, RequestOptions options) throws IOException; } @FunctionalInterface protected interface AsyncMethod { + 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); } 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 448ff0138d3ac..dd58f755c335e 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 @@ -107,6 +107,8 @@ public void testIndicesExists() throws IOException { boolean response = execute( request, highLevelClient().indices()::exists, + highLevelClient().indices()::existsAsync, + highLevelClient().indices()::exists, highLevelClient().indices()::existsAsync ); assertTrue(response); @@ -122,6 +124,8 @@ public void testIndicesExists() throws IOException { boolean response = execute( request, highLevelClient().indices()::exists, + highLevelClient().indices()::existsAsync, + highLevelClient().indices()::exists, highLevelClient().indices()::existsAsync ); assertFalse(response); @@ -140,6 +144,8 @@ public void testIndicesExists() throws IOException { boolean response = execute( request, highLevelClient().indices()::exists, + highLevelClient().indices()::existsAsync, + highLevelClient().indices()::exists, highLevelClient().indices()::existsAsync ); assertFalse(response); @@ -157,7 +163,8 @@ public void testCreateIndex() throws IOException { CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName); CreateIndexResponse createIndexResponse = - execute(createIndexRequest, highLevelClient().indices()::create, highLevelClient().indices()::createAsync); + execute(createIndexRequest, highLevelClient().indices()::create, highLevelClient().indices()::createAsync, + highLevelClient().indices()::create, highLevelClient().indices()::createAsync); assertTrue(createIndexResponse.isAcknowledged()); assertTrue(indexExists(indexName)); @@ -185,7 +192,8 @@ public void testCreateIndex() throws IOException { createIndexRequest.mapping("type_name", mappingBuilder); CreateIndexResponse createIndexResponse = - execute(createIndexRequest, highLevelClient().indices()::create, highLevelClient().indices()::createAsync); + execute(createIndexRequest, highLevelClient().indices()::create, highLevelClient().indices()::createAsync, + highLevelClient().indices()::create, highLevelClient().indices()::createAsync); assertTrue(createIndexResponse.isAcknowledged()); Map getIndexResponse = getAsMap(indexName); @@ -320,7 +328,8 @@ public void testPutMapping() throws IOException { putMappingRequest.source(mappingBuilder); PutMappingResponse putMappingResponse = - execute(putMappingRequest, highLevelClient().indices()::putMapping, highLevelClient().indices()::putMappingAsync); + execute(putMappingRequest, highLevelClient().indices()::putMapping, highLevelClient().indices()::putMappingAsync, + highLevelClient().indices()::putMapping, highLevelClient().indices()::putMappingAsync); assertTrue(putMappingResponse.isAcknowledged()); Map getIndexResponse = getAsMap(indexName); @@ -336,7 +345,8 @@ public void testDeleteIndex() throws IOException { DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(indexName); DeleteIndexResponse deleteIndexResponse = - execute(deleteIndexRequest, highLevelClient().indices()::delete, highLevelClient().indices()::deleteAsync); + execute(deleteIndexRequest, highLevelClient().indices()::delete, highLevelClient().indices()::deleteAsync, + highLevelClient().indices()::delete, highLevelClient().indices()::deleteAsync); assertTrue(deleteIndexResponse.isAcknowledged()); assertFalse(indexExists(indexName)); @@ -349,7 +359,8 @@ public void testDeleteIndex() throws IOException { DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(nonExistentIndex); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> execute(deleteIndexRequest, highLevelClient().indices()::delete, highLevelClient().indices()::deleteAsync)); + () -> execute(deleteIndexRequest, highLevelClient().indices()::delete, highLevelClient().indices()::deleteAsync, + highLevelClient().indices()::delete, highLevelClient().indices()::deleteAsync)); assertEquals(RestStatus.NOT_FOUND, exception.status()); } } @@ -368,6 +379,7 @@ public void testUpdateAliases() throws IOException { 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)); @@ -386,6 +398,7 @@ public void testUpdateAliases() throws IOException { 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)); @@ -397,6 +410,7 @@ public void testUpdateAliases() throws IOException { 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)); @@ -414,7 +428,9 @@ public void testAliasesNonExistentIndex() throws IOException { 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)); @@ -424,7 +440,8 @@ public void testAliasesNonExistentIndex() throws IOException { 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)); + () -> execute(mixedRequest, 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)); @@ -436,6 +453,7 @@ public void testAliasesNonExistentIndex() throws IOException { 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]")); @@ -456,6 +474,7 @@ public void testOpenExistingIndex() throws IOException { OpenIndexRequest openIndexRequest = new OpenIndexRequest(index); OpenIndexResponse openIndexResponse = execute(openIndexRequest, highLevelClient().indices()::open, + highLevelClient().indices()::openAsync, highLevelClient().indices()::open, highLevelClient().indices()::openAsync); assertTrue(openIndexResponse.isAcknowledged()); @@ -469,19 +488,22 @@ public void testOpenNonExistentIndex() throws IOException { OpenIndexRequest openIndexRequest = new OpenIndexRequest(nonExistentIndex); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> execute(openIndexRequest, highLevelClient().indices()::open, highLevelClient().indices()::openAsync)); + () -> execute(openIndexRequest, highLevelClient().indices()::open, highLevelClient().indices()::openAsync, + 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)); + () -> execute(openIndexRequest, highLevelClient().indices()::open, highLevelClient().indices()::openAsync, + highLevelClient().indices()::open, highLevelClient().indices()::openAsync)); assertEquals(RestStatus.NOT_FOUND, strictException.status()); } @@ -493,6 +515,7 @@ public void testCloseExistingIndex() throws IOException { CloseIndexRequest closeIndexRequest = new CloseIndexRequest(index); CloseIndexResponse closeIndexResponse = execute(closeIndexRequest, highLevelClient().indices()::close, + highLevelClient().indices()::closeAsync, highLevelClient().indices()::close, highLevelClient().indices()::closeAsync); assertTrue(closeIndexResponse.isAcknowledged()); @@ -508,7 +531,8 @@ public void testCloseNonExistentIndex() throws IOException { CloseIndexRequest closeIndexRequest = new CloseIndexRequest(nonExistentIndex); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> execute(closeIndexRequest, highLevelClient().indices()::close, highLevelClient().indices()::closeAsync)); + () -> execute(closeIndexRequest, highLevelClient().indices()::close, highLevelClient().indices()::closeAsync, + highLevelClient().indices()::close, highLevelClient().indices()::closeAsync)); assertEquals(RestStatus.NOT_FOUND, exception.status()); } @@ -522,7 +546,8 @@ public void testRefresh() throws IOException { createIndex(index, settings); RefreshRequest refreshRequest = new RefreshRequest(index); RefreshResponse refreshResponse = - execute(refreshRequest, highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync); + execute(refreshRequest, highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync, + highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync); assertThat(refreshResponse.getTotalShards(), equalTo(1)); assertThat(refreshResponse.getSuccessfulShards(), equalTo(1)); assertThat(refreshResponse.getFailedShards(), equalTo(0)); @@ -533,7 +558,8 @@ public void testRefresh() throws IOException { assertFalse(indexExists(nonExistentIndex)); RefreshRequest refreshRequest = new RefreshRequest(nonExistentIndex); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> execute(refreshRequest, highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync)); + () -> execute(refreshRequest, highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync, + highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync)); assertEquals(RestStatus.NOT_FOUND, exception.status()); } } @@ -548,7 +574,8 @@ public void testFlush() throws IOException { createIndex(index, settings); FlushRequest flushRequest = new FlushRequest(index); FlushResponse flushResponse = - execute(flushRequest, highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync); + execute(flushRequest, highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync, + highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync); assertThat(flushResponse.getTotalShards(), equalTo(1)); assertThat(flushResponse.getSuccessfulShards(), equalTo(1)); assertThat(flushResponse.getFailedShards(), equalTo(0)); @@ -559,7 +586,8 @@ public void testFlush() throws IOException { assertFalse(indexExists(nonExistentIndex)); FlushRequest flushRequest = new FlushRequest(nonExistentIndex); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> execute(flushRequest, highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync)); + () -> execute(flushRequest, highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync, + highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync)); assertEquals(RestStatus.NOT_FOUND, exception.status()); } } @@ -607,7 +635,8 @@ public void testClearCache() throws IOException { createIndex(index, settings); ClearIndicesCacheRequest clearCacheRequest = new ClearIndicesCacheRequest(index); ClearIndicesCacheResponse clearCacheResponse = - execute(clearCacheRequest, highLevelClient().indices()::clearCache, highLevelClient().indices()::clearCacheAsync); + execute(clearCacheRequest, highLevelClient().indices()::clearCache, highLevelClient().indices()::clearCacheAsync, + highLevelClient().indices()::clearCache, highLevelClient().indices()::clearCacheAsync); assertThat(clearCacheResponse.getTotalShards(), equalTo(1)); assertThat(clearCacheResponse.getSuccessfulShards(), equalTo(1)); assertThat(clearCacheResponse.getFailedShards(), equalTo(0)); @@ -618,8 +647,8 @@ public void testClearCache() throws IOException { assertFalse(indexExists(nonExistentIndex)); ClearIndicesCacheRequest clearCacheRequest = new ClearIndicesCacheRequest(nonExistentIndex); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> execute(clearCacheRequest, highLevelClient().indices()::clearCache, - highLevelClient().indices()::clearCacheAsync)); + () -> execute(clearCacheRequest, highLevelClient().indices()::clearCache, highLevelClient().indices()::clearCacheAsync, + highLevelClient().indices()::clearCache, highLevelClient().indices()::clearCacheAsync)); assertEquals(RestStatus.NOT_FOUND, exception.status()); } } @@ -634,7 +663,8 @@ public void testForceMerge() throws IOException { createIndex(index, settings); ForceMergeRequest forceMergeRequest = new ForceMergeRequest(index); ForceMergeResponse forceMergeResponse = - execute(forceMergeRequest, highLevelClient().indices()::forceMerge, highLevelClient().indices()::forceMergeAsync); + execute(forceMergeRequest, highLevelClient().indices()::forceMerge, highLevelClient().indices()::forceMergeAsync, + highLevelClient().indices()::forceMerge, highLevelClient().indices()::forceMergeAsync); assertThat(forceMergeResponse.getTotalShards(), equalTo(1)); assertThat(forceMergeResponse.getSuccessfulShards(), equalTo(1)); assertThat(forceMergeResponse.getFailedShards(), equalTo(0)); @@ -645,25 +675,30 @@ public void testForceMerge() throws IOException { assertFalse(indexExists(nonExistentIndex)); ForceMergeRequest forceMergeRequest = new ForceMergeRequest(nonExistentIndex); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> execute(forceMergeRequest, highLevelClient().indices()::forceMerge, highLevelClient().indices()::forceMergeAsync)); + () -> execute(forceMergeRequest, highLevelClient().indices()::forceMerge, highLevelClient().indices()::forceMergeAsync, + 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)); + assertFalse(execute(getAliasesRequest, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync, + 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)); + assertTrue(execute(getAliasesRequest, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync, + 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)); + assertTrue(execute(getAliasesRequest2, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync, + highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync)); getAliasesRequest2.indices("does_not_exist"); - assertFalse(execute(getAliasesRequest2, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync)); + assertFalse(execute(getAliasesRequest2, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync, + highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync)); } @SuppressWarnings("unchecked") @@ -683,7 +718,8 @@ public void testShrink() throws IOException { .putNull("index.routing.allocation.require._name") .build(); resizeRequest.setTargetIndex(new CreateIndexRequest("target").settings(targetSettings).alias(new Alias("alias"))); - ResizeResponse resizeResponse = highLevelClient().indices().shrink(resizeRequest); + ResizeResponse resizeResponse = execute(resizeRequest, highLevelClient().indices()::shrink, + highLevelClient().indices()::shrinkAsync, highLevelClient().indices()::shrink, highLevelClient().indices()::shrinkAsync); assertTrue(resizeResponse.isAcknowledged()); assertTrue(resizeResponse.isShardsAcknowledged()); Map getIndexResponse = getAsMap("target"); @@ -705,7 +741,8 @@ public void testSplit() throws IOException { 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 = highLevelClient().indices().split(resizeRequest); + ResizeResponse resizeResponse = execute(resizeRequest, highLevelClient().indices()::split, highLevelClient().indices()::splitAsync, + highLevelClient().indices()::split, highLevelClient().indices()::splitAsync); assertTrue(resizeResponse.isAcknowledged()); assertTrue(resizeResponse.isShardsAcknowledged()); Map getIndexResponse = getAsMap("target"); @@ -718,12 +755,13 @@ public void testSplit() throws IOException { } public void testRollover() throws IOException { - highLevelClient().indices().create(new CreateIndexRequest("test").alias(new Alias("alias"))); + highLevelClient().indices().create(new CreateIndexRequest("test").alias(new Alias("alias")), RequestOptions.DEFAULT); RolloverRequest rolloverRequest = new RolloverRequest("alias", "test_new"); rolloverRequest.addMaxIndexDocsCondition(1); { RolloverResponse rolloverResponse = execute(rolloverRequest, highLevelClient().indices()::rollover, + highLevelClient().indices()::rolloverAsync, highLevelClient().indices()::rollover, highLevelClient().indices()::rolloverAsync); assertFalse(rolloverResponse.isRolledOver()); assertFalse(rolloverResponse.isDryRun()); @@ -734,15 +772,16 @@ public void testRollover() throws IOException { assertEquals("test_new", rolloverResponse.getNewIndex()); } - highLevelClient().index(new IndexRequest("test", "type", "1").source("field", "value")); + highLevelClient().index(new IndexRequest("test", "type", "1").source("field", "value"), RequestOptions.DEFAULT); highLevelClient().index(new IndexRequest("test", "type", "2").source("field", "value") - .setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL)); + .setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL), RequestOptions.DEFAULT); //without the refresh the rollover may not happen as the number of docs seen may be off { 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()); @@ -757,6 +796,7 @@ public void testRollover() throws IOException { 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()); @@ -791,6 +831,7 @@ public void testIndexPutSettings() throws IOException { 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()); @@ -801,6 +842,7 @@ public void testIndexPutSettings() throws IOException { 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, " @@ -811,6 +853,7 @@ public void testIndexPutSettings() throws IOException { closeIndex(index); response = execute(staticSettingRequest, highLevelClient().indices()::putSettings, + highLevelClient().indices()::putSettingsAsync, highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync); assertTrue(response.isAcknowledged()); openIndex(index); @@ -821,6 +864,7 @@ public void testIndexPutSettings() throws IOException { 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, " @@ -848,12 +892,14 @@ public void testIndexPutSettingNonExistent() throws IOException { 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/PingAndInfoIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/PingAndInfoIT.java index b4d8828eb7e6f..057ea49f9a969 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/PingAndInfoIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/PingAndInfoIT.java @@ -28,12 +28,12 @@ public class PingAndInfoIT extends ESRestHighLevelClientTestCase { public void testPing() throws IOException { - assertTrue(highLevelClient().ping()); + assertTrue(highLevelClient().ping(RequestOptions.DEFAULT)); } @SuppressWarnings("unchecked") public void testInfo() throws IOException { - MainResponse info = highLevelClient().info(); + MainResponse info = highLevelClient().info(RequestOptions.DEFAULT); // compare with what the low level client outputs Map infoAsMap = entityAsMap(adminClient().performRequest(HttpGet.METHOD_NAME, "/")); assertEquals(infoAsMap.get("cluster_name"), info.getClusterName().value()); 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 9497bdded0549..1e12f3f5e62f6 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,8 @@ public void testRankEvalRequest() throws IOException { RankEvalSpec spec = new RankEvalSpec(specifications, metric); RankEvalRequest rankEvalRequest = new RankEvalRequest(spec, new String[] { "index", "index2" }); - RankEvalResponse response = execute(rankEvalRequest, highLevelClient()::rankEval, - highLevelClient()::rankEvalAsync); + RankEvalResponse response = execute(rankEvalRequest, highLevelClient()::rankEval, highLevelClient()::rankEvalAsync, + 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,7 +117,8 @@ public void testRankEvalRequest() throws IOException { // 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); + response = execute(rankEvalRequest, highLevelClient()::rankEval, highLevelClient()::rankEvalAsync, + 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 5ca9b05f73adf..9084a547c162d 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 @@ -20,7 +20,6 @@ package org.elasticsearch.client; import com.fasterxml.jackson.core.JsonParseException; - import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpHost; @@ -28,10 +27,7 @@ import org.apache.http.ProtocolVersion; import org.apache.http.RequestLine; import org.apache.http.StatusLine; -import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpHead; -import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ByteArrayEntity; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; @@ -77,9 +73,6 @@ import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.InternalAggregationTestCase; import org.junit.Before; -import org.mockito.ArgumentMatcher; -import org.mockito.internal.matchers.ArrayEquals; -import org.mockito.internal.matchers.VarargMatcher; import java.io.IOException; import java.net.SocketTimeoutException; @@ -124,25 +117,22 @@ public void testCloseIsIdempotent() throws IOException { } public void testPingSuccessful() throws IOException { - Header[] headers = randomHeaders(random(), "Header"); Response response = mock(Response.class); when(response.getStatusLine()).thenReturn(newStatusLine(RestStatus.OK)); when(restClient.performRequest(any(Request.class))).thenReturn(response); - assertTrue(restHighLevelClient.ping(headers)); + assertTrue(restHighLevelClient.ping(RequestOptions.DEFAULT)); } public void testPing404NotFound() throws IOException { - Header[] headers = randomHeaders(random(), "Header"); Response response = mock(Response.class); when(response.getStatusLine()).thenReturn(newStatusLine(RestStatus.NOT_FOUND)); when(restClient.performRequest(any(Request.class))).thenReturn(response); - assertFalse(restHighLevelClient.ping(headers)); + assertFalse(restHighLevelClient.ping(RequestOptions.DEFAULT)); } public void testPingSocketTimeout() throws IOException { - Header[] headers = randomHeaders(random(), "Header"); when(restClient.performRequest(any(Request.class))).thenThrow(new SocketTimeoutException()); - expectThrows(SocketTimeoutException.class, () -> restHighLevelClient.ping(headers)); + expectThrows(SocketTimeoutException.class, () -> restHighLevelClient.ping(RequestOptions.DEFAULT)); } public void testInfo() throws IOException { @@ -150,18 +140,17 @@ public void testInfo() throws IOException { MainResponse testInfo = new MainResponse("nodeName", Version.CURRENT, new ClusterName("clusterName"), "clusterUuid", Build.CURRENT); mockResponse(testInfo); - MainResponse receivedInfo = restHighLevelClient.info(headers); + MainResponse receivedInfo = restHighLevelClient.info(RequestOptions.DEFAULT); assertEquals(testInfo, receivedInfo); } public void testSearchScroll() throws IOException { - Header[] headers = randomHeaders(random(), "Header"); SearchResponse mockSearchResponse = new SearchResponse(new SearchResponseSections(SearchHits.empty(), InternalAggregations.EMPTY, null, false, false, null, 1), randomAlphaOfLengthBetween(5, 10), 5, 5, 0, 100, ShardSearchFailure.EMPTY_ARRAY, SearchResponse.Clusters.EMPTY); mockResponse(mockSearchResponse); - SearchResponse searchResponse = restHighLevelClient.searchScroll(new SearchScrollRequest(randomAlphaOfLengthBetween(5, 10)), - headers); + SearchResponse searchResponse = restHighLevelClient.searchScroll( + new SearchScrollRequest(randomAlphaOfLengthBetween(5, 10)), RequestOptions.DEFAULT); assertEquals(mockSearchResponse.getScrollId(), searchResponse.getScrollId()); assertEquals(0, searchResponse.getHits().totalHits); assertEquals(5, searchResponse.getTotalShards()); @@ -170,12 +159,11 @@ public void testSearchScroll() throws IOException { } public void testClearScroll() throws IOException { - Header[] headers = randomHeaders(random(), "Header"); ClearScrollResponse mockClearScrollResponse = new ClearScrollResponse(randomBoolean(), randomIntBetween(0, Integer.MAX_VALUE)); mockResponse(mockClearScrollResponse); ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); clearScrollRequest.addScrollId(randomAlphaOfLengthBetween(5, 10)); - ClearScrollResponse clearScrollResponse = restHighLevelClient.clearScroll(clearScrollRequest, headers); + ClearScrollResponse clearScrollResponse = restHighLevelClient.clearScroll(clearScrollRequest, RequestOptions.DEFAULT); assertEquals(mockClearScrollResponse.isSucceeded(), clearScrollResponse.isSucceeded()); assertEquals(mockClearScrollResponse.getNumFreed(), clearScrollResponse.getNumFreed()); } 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 e147642fc73bd..80d09acf2817d 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,7 +164,8 @@ public void testSearchNoQuery() throws IOException { 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); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, + highLevelClient()::search, highLevelClient()::searchAsync); assertSearchHeader(searchResponse); assertNull(searchResponse.getAggregations()); assertNull(searchResponse.getSuggest()); @@ -190,7 +191,8 @@ public void testSearchWithTermsAgg() throws IOException { searchSourceBuilder.aggregation(new TermsAggregationBuilder("agg1", ValueType.STRING).field("type.keyword")); searchSourceBuilder.size(0); searchRequest.source(searchSourceBuilder); - SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, + highLevelClient()::search, highLevelClient()::searchAsync); assertSearchHeader(searchResponse); assertNull(searchResponse.getSuggest()); assertEquals(Collections.emptyMap(), searchResponse.getProfileResults()); @@ -216,7 +218,8 @@ public void testSearchWithRangeAgg() throws IOException { searchRequest.source(searchSourceBuilder); ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, - () -> execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync)); + () -> execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, + highLevelClient()::search, highLevelClient()::searchAsync)); assertEquals(RestStatus.BAD_REQUEST, exception.status()); } @@ -226,7 +229,8 @@ public void testSearchWithRangeAgg() throws IOException { .addRange("first", 0, 30).addRange("second", 31, 200)); searchSourceBuilder.size(0); searchRequest.source(searchSourceBuilder); - SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, + highLevelClient()::search, highLevelClient()::searchAsync); assertSearchHeader(searchResponse); assertNull(searchResponse.getSuggest()); assertEquals(Collections.emptyMap(), searchResponse.getProfileResults()); @@ -257,7 +261,8 @@ public void testSearchWithTermsAndRangeAgg() throws IOException { searchSourceBuilder.aggregation(agg); searchSourceBuilder.size(0); searchRequest.source(searchSourceBuilder); - SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, + highLevelClient()::search, highLevelClient()::searchAsync); assertSearchHeader(searchResponse); assertNull(searchResponse.getSuggest()); assertEquals(Collections.emptyMap(), searchResponse.getProfileResults()); @@ -308,7 +313,8 @@ public void testSearchWithMatrixStats() throws IOException { searchSourceBuilder.aggregation(new MatrixStatsAggregationBuilder("agg1").fields(Arrays.asList("num", "num2"))); searchSourceBuilder.size(0); searchRequest.source(searchSourceBuilder); - SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, + highLevelClient()::search, highLevelClient()::searchAsync); assertSearchHeader(searchResponse); assertNull(searchResponse.getSuggest()); assertEquals(Collections.emptyMap(), searchResponse.getProfileResults()); @@ -397,7 +403,8 @@ public void testSearchWithParentJoin() throws IOException { SearchRequest searchRequest = new SearchRequest(indexName); searchRequest.source(searchSourceBuilder); - SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, + highLevelClient()::search, highLevelClient()::searchAsync); assertSearchHeader(searchResponse); assertNull(searchResponse.getSuggest()); assertEquals(Collections.emptyMap(), searchResponse.getProfileResults()); @@ -437,7 +444,8 @@ public void testSearchWithSuggest() throws IOException { searchSourceBuilder.size(0); searchRequest.source(searchSourceBuilder); - SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, + highLevelClient()::search, highLevelClient()::searchAsync); assertSearchHeader(searchResponse); assertNull(searchResponse.getAggregations()); assertEquals(Collections.emptyMap(), searchResponse.getProfileResults()); @@ -469,7 +477,8 @@ public void testSearchWithWeirdScriptFields() throws Exception { { SearchRequest searchRequest = new SearchRequest("test").source(SearchSourceBuilder.searchSource() .scriptField("result", new Script("null"))); - SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, + highLevelClient()::search, highLevelClient()::searchAsync); SearchHit searchHit = searchResponse.getHits().getAt(0); List values = searchHit.getFields().get("result").getValues(); assertNotNull(values); @@ -479,7 +488,8 @@ public void testSearchWithWeirdScriptFields() throws Exception { { SearchRequest searchRequest = new SearchRequest("test").source(SearchSourceBuilder.searchSource() .scriptField("result", new Script("new HashMap()"))); - SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, + highLevelClient()::search, highLevelClient()::searchAsync); SearchHit searchHit = searchResponse.getHits().getAt(0); List values = searchHit.getFields().get("result").getValues(); assertNotNull(values); @@ -491,7 +501,8 @@ public void testSearchWithWeirdScriptFields() throws Exception { { SearchRequest searchRequest = new SearchRequest("test").source(SearchSourceBuilder.searchSource() .scriptField("result", new Script("new String[]{}"))); - SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, + highLevelClient()::search, highLevelClient()::searchAsync); SearchHit searchHit = searchResponse.getHits().getAt(0); List values = searchHit.getFields().get("result").getValues(); assertNotNull(values); @@ -513,7 +524,8 @@ public void testSearchScroll() throws Exception { 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); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, + highLevelClient()::search, highLevelClient()::searchAsync); try { long counter = 0; @@ -525,6 +537,7 @@ public void testSearchScroll() throws Exception { } searchResponse = execute(new SearchScrollRequest(searchResponse.getScrollId()).scroll(TimeValue.timeValueMinutes(2)), + highLevelClient()::searchScroll, highLevelClient()::searchScrollAsync, highLevelClient()::searchScroll, highLevelClient()::searchScrollAsync); assertThat(searchResponse.getHits().getTotalHits(), equalTo(100L)); @@ -534,6 +547,7 @@ public void testSearchScroll() throws Exception { } searchResponse = execute(new SearchScrollRequest(searchResponse.getScrollId()).scroll(TimeValue.timeValueMinutes(2)), + highLevelClient()::searchScroll, highLevelClient()::searchScrollAsync, highLevelClient()::searchScroll, highLevelClient()::searchScrollAsync); assertThat(searchResponse.getHits().getTotalHits(), equalTo(100L)); @@ -545,14 +559,14 @@ public void testSearchScroll() throws Exception { ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); clearScrollRequest.addScrollId(searchResponse.getScrollId()); ClearScrollResponse clearScrollResponse = execute(clearScrollRequest, - // Not using a method reference to work around https://bugs.eclipse.org/bugs/show_bug.cgi?id=517951 - (request, headers) -> highLevelClient().clearScroll(request, headers), - (request, listener, headers) -> highLevelClient().clearScrollAsync(request, listener, headers)); + 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)); @@ -574,7 +588,8 @@ public void testMultiSearch() throws Exception { multiSearchRequest.add(searchRequest3); MultiSearchResponse multiSearchResponse = - execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync); + execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync, + highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync); assertThat(multiSearchResponse.getTook().millis(), Matchers.greaterThanOrEqualTo(0L)); assertThat(multiSearchResponse.getResponses().length, Matchers.equalTo(3)); @@ -616,7 +631,8 @@ public void testMultiSearch_withAgg() throws Exception { multiSearchRequest.add(searchRequest3); MultiSearchResponse multiSearchResponse = - execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync); + execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync, + highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync); assertThat(multiSearchResponse.getTook().millis(), Matchers.greaterThanOrEqualTo(0L)); assertThat(multiSearchResponse.getResponses().length, Matchers.equalTo(3)); @@ -664,7 +680,8 @@ public void testMultiSearch_withQuery() throws Exception { multiSearchRequest.add(searchRequest3); MultiSearchResponse multiSearchResponse = - execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync); + execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync, + highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync); assertThat(multiSearchResponse.getTook().millis(), Matchers.greaterThanOrEqualTo(0L)); assertThat(multiSearchResponse.getResponses().length, Matchers.equalTo(3)); @@ -727,7 +744,8 @@ public void testMultiSearch_failure() throws Exception { multiSearchRequest.add(searchRequest2); MultiSearchResponse multiSearchResponse = - execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync); + execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync, + 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 6641aa2fc7d25..ef92e28a07280 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 @@ -48,6 +48,7 @@ import org.elasticsearch.action.update.UpdateResponse; import org.elasticsearch.client.ESRestHighLevelClientTestCase; import org.elasticsearch.client.Request; +import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.Response; import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.common.Strings; @@ -72,13 +73,12 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import static java.util.Collections.singletonMap; import static org.hamcrest.Matchers.arrayWithSize; -import static org.hamcrest.Matchers.hasEntry; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.hasEntry; import static org.hamcrest.Matchers.hasKey; import static org.hamcrest.Matchers.not; -import static java.util.Collections.emptyMap; -import static java.util.Collections.singletonMap; /** * This class is used to generate the Java CRUD API documentation. @@ -112,7 +112,7 @@ public void testIndex() throws Exception { IndexRequest indexRequest = new IndexRequest("posts", "doc", "1") .source(jsonMap); // <1> //end::index-request-map - IndexResponse indexResponse = client.index(indexRequest); + IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT); assertEquals(indexResponse.getResult(), DocWriteResponse.Result.CREATED); } { @@ -128,7 +128,7 @@ public void testIndex() throws Exception { IndexRequest indexRequest = new IndexRequest("posts", "doc", "1") .source(builder); // <1> //end::index-request-xcontent - IndexResponse indexResponse = client.index(indexRequest); + IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT); assertEquals(indexResponse.getResult(), DocWriteResponse.Result.UPDATED); } { @@ -138,7 +138,7 @@ public void testIndex() throws Exception { "postDate", new Date(), "message", "trying out Elasticsearch"); // <1> //end::index-request-shortcut - IndexResponse indexResponse = client.index(indexRequest); + IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT); assertEquals(indexResponse.getResult(), DocWriteResponse.Result.UPDATED); } { @@ -156,7 +156,7 @@ public void testIndex() throws Exception { //end::index-request-string // tag::index-execute - IndexResponse indexResponse = client.index(request); + IndexResponse indexResponse = client.index(request, RequestOptions.DEFAULT); // end::index-execute assertEquals(indexResponse.getResult(), DocWriteResponse.Result.UPDATED); @@ -214,7 +214,7 @@ public void testIndex() throws Exception { .source("field", "value") .version(1); try { - IndexResponse response = client.index(request); + IndexResponse response = client.index(request, RequestOptions.DEFAULT); } catch(ElasticsearchException e) { if (e.status() == RestStatus.CONFLICT) { // <1> @@ -228,7 +228,7 @@ public void testIndex() throws Exception { .source("field", "value") .opType(DocWriteRequest.OpType.CREATE); try { - IndexResponse response = client.index(request); + IndexResponse response = client.index(request, RequestOptions.DEFAULT); } catch(ElasticsearchException e) { if (e.status() == RestStatus.CONFLICT) { // <1> @@ -257,7 +257,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::index-execute-async - client.indexAsync(request, listener); // <1> + client.indexAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::index-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -268,7 +268,7 @@ public void testUpdate() throws Exception { RestHighLevelClient client = highLevelClient(); { IndexRequest indexRequest = new IndexRequest("posts", "doc", "1").source("field", 0); - IndexResponse indexResponse = client.index(indexRequest); + IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT); assertSame(indexResponse.status(), RestStatus.CREATED); Request request = new Request("POST", "/_scripts/increment-field"); @@ -297,7 +297,7 @@ public void testUpdate() throws Exception { "ctx._source.field += params.count", parameters); // <2> request.script(inline); // <3> //end::update-request-with-inline-script - UpdateResponse updateResponse = client.update(request); + UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT); assertEquals(updateResponse.getResult(), DocWriteResponse.Result.UPDATED); assertEquals(4, updateResponse.getGetResult().getSource().get("field")); @@ -307,7 +307,7 @@ public void testUpdate() throws Exception { new Script(ScriptType.STORED, null, "increment-field", parameters); // <1> request.script(stored); // <2> //end::update-request-with-stored-script - updateResponse = client.update(request); + updateResponse = client.update(request, RequestOptions.DEFAULT); assertEquals(updateResponse.getResult(), DocWriteResponse.Result.UPDATED); assertEquals(8, updateResponse.getGetResult().getSource().get("field")); } @@ -319,7 +319,7 @@ public void testUpdate() throws Exception { UpdateRequest request = new UpdateRequest("posts", "doc", "1") .doc(jsonMap); // <1> //end::update-request-with-doc-as-map - UpdateResponse updateResponse = client.update(request); + UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT); assertEquals(updateResponse.getResult(), DocWriteResponse.Result.UPDATED); } { @@ -334,7 +334,7 @@ public void testUpdate() throws Exception { UpdateRequest request = new UpdateRequest("posts", "doc", "1") .doc(builder); // <1> //end::update-request-with-doc-as-xcontent - UpdateResponse updateResponse = client.update(request); + UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT); assertEquals(updateResponse.getResult(), DocWriteResponse.Result.UPDATED); } { @@ -343,7 +343,7 @@ public void testUpdate() throws Exception { .doc("updated", new Date(), "reason", "daily update"); // <1> //end::update-request-shortcut - UpdateResponse updateResponse = client.update(request); + UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT); assertEquals(updateResponse.getResult(), DocWriteResponse.Result.UPDATED); } { @@ -357,7 +357,7 @@ public void testUpdate() throws Exception { //end::update-request-with-doc-as-string request.fetchSource(true); // tag::update-execute - UpdateResponse updateResponse = client.update(request); + UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT); // end::update-execute assertEquals(updateResponse.getResult(), DocWriteResponse.Result.UPDATED); @@ -406,7 +406,7 @@ public void testUpdate() throws Exception { UpdateRequest request = new UpdateRequest("posts", "type", "does_not_exist") .doc("field", "value"); try { - UpdateResponse updateResponse = client.update(request); + UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT); } catch (ElasticsearchException e) { if (e.status() == RestStatus.NOT_FOUND) { // <1> @@ -420,7 +420,7 @@ public void testUpdate() throws Exception { .doc("field", "value") .version(1); try { - UpdateResponse updateResponse = client.update(request); + UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT); } catch(ElasticsearchException e) { if (e.status() == RestStatus.CONFLICT) { // <1> @@ -433,7 +433,7 @@ public void testUpdate() throws Exception { //tag::update-request-no-source request.fetchSource(true); // <1> //end::update-request-no-source - UpdateResponse updateResponse = client.update(request); + UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT); assertEquals(updateResponse.getResult(), DocWriteResponse.Result.UPDATED); assertNotNull(updateResponse.getGetResult()); assertEquals(3, updateResponse.getGetResult().sourceAsMap().size()); @@ -445,7 +445,7 @@ public void testUpdate() throws Exception { String[] excludes = Strings.EMPTY_ARRAY; request.fetchSource(new FetchSourceContext(true, includes, excludes)); // <1> //end::update-request-source-include - UpdateResponse updateResponse = client.update(request); + UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT); assertEquals(updateResponse.getResult(), DocWriteResponse.Result.UPDATED); Map sourceAsMap = updateResponse.getGetResult().sourceAsMap(); assertEquals(2, sourceAsMap.size()); @@ -459,7 +459,7 @@ public void testUpdate() throws Exception { String[] excludes = new String[]{"updated"}; request.fetchSource(new FetchSourceContext(true, includes, excludes)); // <1> //end::update-request-source-exclude - UpdateResponse updateResponse = client.update(request); + UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT); assertEquals(updateResponse.getResult(), DocWriteResponse.Result.UPDATED); Map sourceAsMap = updateResponse.getGetResult().sourceAsMap(); assertEquals(2, sourceAsMap.size()); @@ -525,7 +525,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::update-execute-async - client.updateAsync(request, listener); // <1> + client.updateAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::update-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -537,7 +537,7 @@ public void testDelete() throws Exception { { IndexRequest indexRequest = new IndexRequest("posts", "doc", "1").source("field", "value"); - IndexResponse indexResponse = client.index(indexRequest); + IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT); assertSame(indexResponse.status(), RestStatus.CREATED); } @@ -550,7 +550,7 @@ public void testDelete() throws Exception { // end::delete-request // tag::delete-execute - DeleteResponse deleteResponse = client.delete(request); + DeleteResponse deleteResponse = client.delete(request, RequestOptions.DEFAULT); // end::delete-execute assertSame(deleteResponse.getResult(), DocWriteResponse.Result.DELETED); @@ -595,7 +595,7 @@ public void testDelete() throws Exception { { // tag::delete-notfound DeleteRequest request = new DeleteRequest("posts", "doc", "does_not_exist"); - DeleteResponse deleteResponse = client.delete(request); + DeleteResponse deleteResponse = client.delete(request, RequestOptions.DEFAULT); if (deleteResponse.getResult() == DocWriteResponse.Result.NOT_FOUND) { // <1> } @@ -603,13 +603,14 @@ public void testDelete() throws Exception { } { - IndexResponse indexResponse = client.index(new IndexRequest("posts", "doc", "1").source("field", "value")); + IndexResponse indexResponse = client.index(new IndexRequest("posts", "doc", "1").source("field", "value") + , RequestOptions.DEFAULT); assertSame(indexResponse.status(), RestStatus.CREATED); // tag::delete-conflict try { DeleteRequest request = new DeleteRequest("posts", "doc", "1").version(2); - DeleteResponse deleteResponse = client.delete(request); + DeleteResponse deleteResponse = client.delete(request, RequestOptions.DEFAULT); } catch (ElasticsearchException exception) { if (exception.status() == RestStatus.CONFLICT) { // <1> @@ -618,7 +619,8 @@ public void testDelete() throws Exception { // end::delete-conflict } { - IndexResponse indexResponse = client.index(new IndexRequest("posts", "doc", "async").source("field", "value")); + IndexResponse indexResponse = client.index(new IndexRequest("posts", "doc", "async").source("field", "value"), + RequestOptions.DEFAULT); assertSame(indexResponse.status(), RestStatus.CREATED); DeleteRequest request = new DeleteRequest("posts", "doc", "async"); @@ -642,7 +644,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::delete-execute-async - client.deleteAsync(request, listener); // <1> + client.deleteAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::delete-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -662,7 +664,7 @@ public void testBulk() throws Exception { .source(XContentType.JSON,"field", "baz")); // end::bulk-request // tag::bulk-execute - BulkResponse bulkResponse = client.bulk(request); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); // end::bulk-execute assertSame(bulkResponse.status(), RestStatus.OK); assertFalse(bulkResponse.hasFailures()); @@ -676,7 +678,7 @@ public void testBulk() throws Exception { request.add(new IndexRequest("posts", "doc", "4") // <3> .source(XContentType.JSON,"field", "baz")); // end::bulk-request-with-mixed-operations - BulkResponse bulkResponse = client.bulk(request); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); assertSame(bulkResponse.status(), RestStatus.OK); assertFalse(bulkResponse.hasFailures()); @@ -775,7 +777,7 @@ public void testGet() throws Exception { .source("user", "kimchy", "postDate", new Date(), "message", "trying out Elasticsearch"); - IndexResponse indexResponse = client.index(indexRequest); + IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT); assertEquals(indexResponse.getResult(), DocWriteResponse.Result.CREATED); } { @@ -787,7 +789,7 @@ public void testGet() throws Exception { //end::get-request //tag::get-execute - GetResponse getResponse = client.get(getRequest); + GetResponse getResponse = client.get(getRequest, RequestOptions.DEFAULT); //end::get-execute assertTrue(getResponse.isExists()); assertEquals(3, getResponse.getSourceAsMap().size()); @@ -810,7 +812,7 @@ public void testGet() throws Exception { //tag::get-request-no-source request.fetchSourceContext(FetchSourceContext.DO_NOT_FETCH_SOURCE); // <1> //end::get-request-no-source - GetResponse getResponse = client.get(request); + GetResponse getResponse = client.get(request, RequestOptions.DEFAULT); assertNull(getResponse.getSourceInternal()); } { @@ -822,7 +824,7 @@ public void testGet() throws Exception { new FetchSourceContext(true, includes, excludes); request.fetchSourceContext(fetchSourceContext); // <1> //end::get-request-source-include - GetResponse getResponse = client.get(request); + GetResponse getResponse = client.get(request, RequestOptions.DEFAULT); Map sourceAsMap = getResponse.getSourceAsMap(); assertEquals(2, sourceAsMap.size()); assertEquals("trying out Elasticsearch", sourceAsMap.get("message")); @@ -837,7 +839,7 @@ public void testGet() throws Exception { new FetchSourceContext(true, includes, excludes); request.fetchSourceContext(fetchSourceContext); // <1> //end::get-request-source-exclude - GetResponse getResponse = client.get(request); + GetResponse getResponse = client.get(request, RequestOptions.DEFAULT); Map sourceAsMap = getResponse.getSourceAsMap(); assertEquals(2, sourceAsMap.size()); assertEquals("kimchy", sourceAsMap.get("user")); @@ -847,7 +849,7 @@ public void testGet() throws Exception { GetRequest request = new GetRequest("posts", "doc", "1"); //tag::get-request-stored request.storedFields("message"); // <1> - GetResponse getResponse = client.get(request); + GetResponse getResponse = client.get(request, RequestOptions.DEFAULT); String message = getResponse.getField("message").getValue(); // <2> //end::get-request-stored assertEquals("trying out Elasticsearch", message); @@ -897,7 +899,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); //tag::get-execute-async - client.getAsync(request, listener); // <1> + client.getAsync(request, RequestOptions.DEFAULT, listener); // <1> //end::get-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -906,7 +908,7 @@ public void onFailure(Exception e) { //tag::get-indexnotfound GetRequest request = new GetRequest("does_not_exist", "doc", "1"); try { - GetResponse getResponse = client.get(request); + GetResponse getResponse = client.get(request, RequestOptions.DEFAULT); } catch (ElasticsearchException e) { if (e.status() == RestStatus.NOT_FOUND) { // <1> @@ -918,7 +920,7 @@ public void onFailure(Exception e) { // tag::get-conflict try { GetRequest request = new GetRequest("posts", "doc", "1").version(2); - GetResponse getResponse = client.get(request); + GetResponse getResponse = client.get(request, RequestOptions.DEFAULT); } catch (ElasticsearchException exception) { if (exception.status() == RestStatus.CONFLICT) { // <1> @@ -940,7 +942,7 @@ public void testExists() throws Exception { // end::exists-request { // tag::exists-execute - boolean exists = client.exists(getRequest); + boolean exists = client.exists(getRequest, RequestOptions.DEFAULT); // end::exists-execute assertFalse(exists); } @@ -964,7 +966,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::exists-execute-async - client.existsAsync(getRequest, listener); // <1> + client.existsAsync(getRequest, RequestOptions.DEFAULT, listener); // <1> // end::exists-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -1091,7 +1093,7 @@ public void testMultiGet() throws Exception { source.put("baz", "val3"); client.index(new IndexRequest("index", "type", "example_id") .source(source) - .setRefreshPolicy(RefreshPolicy.IMMEDIATE)); + .setRefreshPolicy(RefreshPolicy.IMMEDIATE), RequestOptions.DEFAULT); { // tag::multi-get-request @@ -1120,7 +1122,7 @@ public void testMultiGet() throws Exception { // end::multi-get-request-top-level-extras // tag::multi-get-execute - MultiGetResponse response = client.multiGet(request); + MultiGetResponse response = client.multiGet(request, RequestOptions.DEFAULT); // end::multi-get-execute // tag::multi-get-response @@ -1184,7 +1186,7 @@ public void onFailure(Exception e) { request.add(new MultiGetRequest.Item("index", "type", "example_id") .fetchSourceContext(FetchSourceContext.DO_NOT_FETCH_SOURCE)); // <1> // end::multi-get-request-no-source - MultiGetItemResponse item = unwrapAndAssertExample(client.multiGet(request)); + MultiGetItemResponse item = unwrapAndAssertExample(client.multiGet(request, RequestOptions.DEFAULT)); assertNull(item.getResponse().getSource()); } { @@ -1197,7 +1199,7 @@ public void onFailure(Exception e) { request.add(new MultiGetRequest.Item("index", "type", "example_id") .fetchSourceContext(fetchSourceContext)); // <1> // end::multi-get-request-source-include - MultiGetItemResponse item = unwrapAndAssertExample(client.multiGet(request)); + MultiGetItemResponse item = unwrapAndAssertExample(client.multiGet(request, RequestOptions.DEFAULT)); assertThat(item.getResponse().getSource(), hasEntry("foo", "val1")); assertThat(item.getResponse().getSource(), hasEntry("bar", "val2")); assertThat(item.getResponse().getSource(), not(hasKey("baz"))); @@ -1212,7 +1214,7 @@ public void onFailure(Exception e) { request.add(new MultiGetRequest.Item("index", "type", "example_id") .fetchSourceContext(fetchSourceContext)); // <1> // end::multi-get-request-source-exclude - MultiGetItemResponse item = unwrapAndAssertExample(client.multiGet(request)); + MultiGetItemResponse item = unwrapAndAssertExample(client.multiGet(request, RequestOptions.DEFAULT)); assertThat(item.getResponse().getSource(), not(hasKey("foo"))); assertThat(item.getResponse().getSource(), not(hasKey("bar"))); assertThat(item.getResponse().getSource(), hasEntry("baz", "val3")); @@ -1222,7 +1224,7 @@ public void onFailure(Exception e) { // tag::multi-get-request-stored request.add(new MultiGetRequest.Item("index", "type", "example_id") .storedFields("foo")); // <1> - MultiGetResponse response = client.multiGet(request); + MultiGetResponse response = client.multiGet(request, RequestOptions.DEFAULT); MultiGetItemResponse item = response.getResponses()[0]; String value = item.getResponse().getField("foo").getValue(); // <2> // end::multi-get-request-stored @@ -1234,7 +1236,7 @@ public void onFailure(Exception e) { MultiGetRequest request = new MultiGetRequest(); request.add(new MultiGetRequest.Item("index", "type", "example_id") .version(1000L)); - MultiGetResponse response = client.multiGet(request); + MultiGetResponse response = client.multiGet(request, RequestOptions.DEFAULT); MultiGetItemResponse item = response.getResponses()[0]; assertNull(item.getResponse()); // <1> Exception e = item.getFailure().getFailure(); // <2> diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/ClusterClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/ClusterClientDocumentationIT.java index 304c5010a47e3..e8dd4025ba94e 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/ClusterClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/ClusterClientDocumentationIT.java @@ -23,27 +23,19 @@ import org.elasticsearch.action.LatchedActionListener; import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest; import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; -import org.elasticsearch.action.ingest.GetPipelineRequest; -import org.elasticsearch.action.ingest.GetPipelineResponse; -import org.elasticsearch.action.ingest.PutPipelineRequest; -import org.elasticsearch.action.ingest.DeletePipelineRequest; -import org.elasticsearch.action.ingest.WritePipelineResponse; import org.elasticsearch.client.ESRestHighLevelClientTestCase; +import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider; -import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeUnit; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.indices.recovery.RecoverySettings; -import org.elasticsearch.ingest.PipelineConfiguration; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; -import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -134,7 +126,7 @@ public void testClusterPutSettings() throws IOException { // end::put-settings-request-masterTimeout // tag::put-settings-execute - ClusterUpdateSettingsResponse response = client.cluster().putSettings(request); + ClusterUpdateSettingsResponse response = client.cluster().putSettings(request, RequestOptions.DEFAULT); // end::put-settings-execute // tag::put-settings-response @@ -150,7 +142,7 @@ public void testClusterPutSettings() throws IOException { request.transientSettings(Settings.builder().putNull(transientSettingKey).build()); // <1> // tag::put-settings-request-reset-transient request.persistentSettings(Settings.builder().putNull(persistentSettingKey)); - ClusterUpdateSettingsResponse resetResponse = client.cluster().putSettings(request); + ClusterUpdateSettingsResponse resetResponse = client.cluster().putSettings(request, RequestOptions.DEFAULT); assertTrue(resetResponse.isAcknowledged()); } @@ -180,7 +172,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::put-settings-execute-async - client.cluster().putSettingsAsync(request, listener); // <1> + client.cluster().putSettingsAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::put-settings-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 fd733b83d5ace..4f36d028a1905 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 @@ -62,6 +62,7 @@ import org.elasticsearch.action.support.DefaultShardOperationFailedException; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.ESRestHighLevelClientTestCase; +import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.SyncedFlushResponse; import org.elasticsearch.common.settings.Settings; @@ -105,7 +106,7 @@ public void testIndicesExist() throws IOException { RestHighLevelClient client = highLevelClient(); { - CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter")); + CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } @@ -124,7 +125,7 @@ public void testIndicesExist() throws IOException { // end::indices-exists-request-optionals // tag::indices-exists-response - boolean exists = client.indices().exists(request); + boolean exists = client.indices().exists(request, RequestOptions.DEFAULT); // end::indices-exists-response assertTrue(exists); } @@ -134,7 +135,7 @@ public void testIndicesExistAsync() throws Exception { RestHighLevelClient client = highLevelClient(); { - CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter")); + CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } @@ -161,7 +162,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::indices-exists-async - client.indices().existsAsync(request, listener); // <1> + client.indices().existsAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::indices-exists-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -171,7 +172,7 @@ public void testDeleteIndex() throws IOException { RestHighLevelClient client = highLevelClient(); { - CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("posts")); + CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("posts"), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } @@ -193,7 +194,7 @@ public void testDeleteIndex() throws IOException { // end::delete-index-request-indicesOptions // tag::delete-index-execute - DeleteIndexResponse deleteIndexResponse = client.indices().delete(request); + DeleteIndexResponse deleteIndexResponse = client.indices().delete(request, RequestOptions.DEFAULT); // end::delete-index-execute // tag::delete-index-response @@ -206,7 +207,7 @@ public void testDeleteIndex() throws IOException { // tag::delete-index-notfound try { DeleteIndexRequest request = new DeleteIndexRequest("does_not_exist"); - client.indices().delete(request); + client.indices().delete(request, RequestOptions.DEFAULT); } catch (ElasticsearchException exception) { if (exception.status() == RestStatus.NOT_FOUND) { // <1> @@ -220,7 +221,7 @@ public void testDeleteIndexAsync() throws Exception { final RestHighLevelClient client = highLevelClient(); { - CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("posts")); + CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("posts"), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } @@ -247,7 +248,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::delete-index-execute-async - client.indices().deleteAsync(request, listener); // <1> + client.indices().deleteAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::delete-index-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -283,7 +284,7 @@ public void testCreateIndex() throws IOException { "}", // <2> XContentType.JSON); // end::create-index-request-mappings - CreateIndexResponse createIndexResponse = client.indices().create(request); + CreateIndexResponse createIndexResponse = client.indices().create(request, RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } @@ -300,7 +301,7 @@ public void testCreateIndex() throws IOException { jsonMap.put("tweet", tweet); request.mapping("tweet", jsonMap); // <1> //end::create-index-mappings-map - CreateIndexResponse createIndexResponse = client.indices().create(request); + CreateIndexResponse createIndexResponse = client.indices().create(request, RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } { @@ -326,7 +327,7 @@ public void testCreateIndex() throws IOException { builder.endObject(); request.mapping("tweet", builder); // <1> //end::create-index-mappings-xcontent - CreateIndexResponse createIndexResponse = client.indices().create(request); + CreateIndexResponse createIndexResponse = client.indices().create(request, RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } { @@ -334,7 +335,7 @@ public void testCreateIndex() throws IOException { //tag::create-index-mappings-shortcut request.mapping("tweet", "message", "type=text"); // <1> //end::create-index-mappings-shortcut - CreateIndexResponse createIndexResponse = client.indices().create(request); + CreateIndexResponse createIndexResponse = client.indices().create(request, RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } @@ -356,7 +357,7 @@ public void testCreateIndex() throws IOException { request.waitForActiveShards(ActiveShardCount.DEFAULT); // <2> // end::create-index-request-waitForActiveShards { - CreateIndexResponse createIndexResponse = client.indices().create(request); + CreateIndexResponse createIndexResponse = client.indices().create(request, RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } @@ -381,7 +382,7 @@ public void testCreateIndex() throws IOException { // end::create-index-whole-source // tag::create-index-execute - CreateIndexResponse createIndexResponse = client.indices().create(request); + CreateIndexResponse createIndexResponse = client.indices().create(request, RequestOptions.DEFAULT); // end::create-index-execute // tag::create-index-response @@ -420,7 +421,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::create-index-execute-async - client.indices().createAsync(request, listener); // <1> + client.indices().createAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::create-index-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -431,7 +432,7 @@ public void testPutMapping() throws IOException { RestHighLevelClient client = highLevelClient(); { - CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter")); + CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } @@ -453,7 +454,7 @@ public void testPutMapping() throws IOException { "}", // <1> XContentType.JSON); // end::put-mapping-request-source - PutMappingResponse putMappingResponse = client.indices().putMapping(request); + PutMappingResponse putMappingResponse = client.indices().putMapping(request, RequestOptions.DEFAULT); assertTrue(putMappingResponse.isAcknowledged()); } @@ -467,7 +468,7 @@ public void testPutMapping() throws IOException { jsonMap.put("properties", properties); request.source(jsonMap); // <1> //end::put-mapping-map - PutMappingResponse putMappingResponse = client.indices().putMapping(request); + PutMappingResponse putMappingResponse = client.indices().putMapping(request, RequestOptions.DEFAULT); assertTrue(putMappingResponse.isAcknowledged()); } { @@ -488,14 +489,14 @@ public void testPutMapping() throws IOException { builder.endObject(); request.source(builder); // <1> //end::put-mapping-xcontent - PutMappingResponse putMappingResponse = client.indices().putMapping(request); + PutMappingResponse putMappingResponse = client.indices().putMapping(request, RequestOptions.DEFAULT); assertTrue(putMappingResponse.isAcknowledged()); } { //tag::put-mapping-shortcut request.source("message", "type=text"); // <1> //end::put-mapping-shortcut - PutMappingResponse putMappingResponse = client.indices().putMapping(request); + PutMappingResponse putMappingResponse = client.indices().putMapping(request, RequestOptions.DEFAULT); assertTrue(putMappingResponse.isAcknowledged()); } @@ -509,7 +510,7 @@ public void testPutMapping() throws IOException { // end::put-mapping-request-masterTimeout // tag::put-mapping-execute - PutMappingResponse putMappingResponse = client.indices().putMapping(request); + PutMappingResponse putMappingResponse = client.indices().putMapping(request, RequestOptions.DEFAULT); // end::put-mapping-execute // tag::put-mapping-response @@ -523,7 +524,7 @@ public void testPutMappingAsync() throws Exception { 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()); } @@ -550,7 +551,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::put-mapping-execute-async - client.indices().putMappingAsync(request, listener); // <1> + client.indices().putMappingAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::put-mapping-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -561,7 +562,7 @@ public void testOpenIndex() throws Exception { RestHighLevelClient client = highLevelClient(); { - CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index")); + CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index"), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } @@ -588,7 +589,7 @@ public void testOpenIndex() throws Exception { // end::open-index-request-indicesOptions // tag::open-index-execute - OpenIndexResponse openIndexResponse = client.indices().open(request); + OpenIndexResponse openIndexResponse = client.indices().open(request, RequestOptions.DEFAULT); // end::open-index-execute // tag::open-index-response @@ -618,7 +619,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::open-index-execute-async - client.indices().openAsync(request, listener); // <1> + client.indices().openAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::open-index-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -628,7 +629,7 @@ public void onFailure(Exception e) { // tag::open-index-notfound try { OpenIndexRequest request = new OpenIndexRequest("does_not_exist"); - client.indices().open(request); + client.indices().open(request, RequestOptions.DEFAULT); } catch (ElasticsearchException exception) { if (exception.status() == RestStatus.BAD_REQUEST) { // <1> @@ -657,7 +658,7 @@ public void testRefreshIndex() throws Exception { // end::refresh-request-indicesOptions // tag::refresh-execute - RefreshResponse refreshResponse = client.indices().refresh(request); + RefreshResponse refreshResponse = client.indices().refresh(request, RequestOptions.DEFAULT); // end::refresh-execute // tag::refresh-response @@ -686,7 +687,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::refresh-execute-async - client.indices().refreshAsync(request, listener); // <1> + client.indices().refreshAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::refresh-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -696,7 +697,7 @@ public void onFailure(Exception e) { // tag::refresh-notfound try { RefreshRequest request = new RefreshRequest("does_not_exist"); - client.indices().refresh(request); + client.indices().refresh(request, RequestOptions.DEFAULT); } catch (ElasticsearchException exception) { if (exception.status() == RestStatus.NOT_FOUND) { // <1> @@ -733,7 +734,7 @@ public void testFlushIndex() throws Exception { // end::flush-request-force // tag::flush-execute - FlushResponse flushResponse = client.indices().flush(request); + FlushResponse flushResponse = client.indices().flush(request, RequestOptions.DEFAULT); // end::flush-execute // tag::flush-response @@ -762,7 +763,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::flush-execute-async - client.indices().flushAsync(request, listener); // <1> + client.indices().flushAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::flush-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -772,7 +773,7 @@ public void onFailure(Exception e) { // tag::flush-notfound try { FlushRequest request = new FlushRequest("does_not_exist"); - client.indices().flush(request); + client.indices().flush(request, RequestOptions.DEFAULT); } catch (ElasticsearchException exception) { if (exception.status() == RestStatus.NOT_FOUND) { // <1> @@ -801,7 +802,7 @@ public void testSyncedFlushIndex() throws Exception { // end::flush-synced-request-indicesOptions // tag::flush-synced-execute - SyncedFlushResponse flushSyncedResponse = client.indices().flushSynced(request); + SyncedFlushResponse flushSyncedResponse = client.indices().flushSynced(request, RequestOptions.DEFAULT); // end::flush-synced-execute // tag::flush-synced-response @@ -845,7 +846,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::flush-synced-execute-async - client.indices().flushSyncedAsync(request, listener); // <1> + client.indices().flushSyncedAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::flush-synced-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -855,7 +856,7 @@ public void onFailure(Exception e) { // tag::flush-synced-notfound try { SyncedFlushRequest request = new SyncedFlushRequest("does_not_exist"); - client.indices().flushSynced(request); + client.indices().flushSynced(request, RequestOptions.DEFAULT); } catch (ElasticsearchException exception) { if (exception.status() == RestStatus.NOT_FOUND) { // <1> @@ -870,7 +871,7 @@ public void testGetSettings() throws Exception { { Settings settings = Settings.builder().put("number_of_shards", 3).build(); - CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index", settings)); + CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index", settings), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } @@ -887,7 +888,7 @@ public void testGetSettings() throws Exception { // end::get-settings-request-indicesOptions // tag::get-settings-execute - GetSettingsResponse getSettingsResponse = client.indices().getSettings(request); + GetSettingsResponse getSettingsResponse = client.indices().getSettings(request, RequestOptions.DEFAULT); // end::get-settings-execute // tag::get-settings-response @@ -922,7 +923,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::get-settings-execute-async - client.indices().getSettingsAsync(request, listener); // <1> + client.indices().getSettingsAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::get-settings-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -933,7 +934,7 @@ public void testGetSettingsWithDefaults() throws Exception { { Settings settings = Settings.builder().put("number_of_shards", 3).build(); - CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index", settings)); + CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index", settings), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } @@ -944,7 +945,7 @@ public void testGetSettingsWithDefaults() throws Exception { request.includeDefaults(true); // <1> // end::get-settings-request-include-defaults - GetSettingsResponse getSettingsResponse = client.indices().getSettings(request); + GetSettingsResponse getSettingsResponse = client.indices().getSettings(request, RequestOptions.DEFAULT); String numberOfShardsString = getSettingsResponse.getSetting("index", "index.number_of_shards"); Settings indexSettings = getSettingsResponse.getIndexToSettings().get("index"); Integer numberOfShards = indexSettings.getAsInt("index.number_of_shards", null); @@ -974,7 +975,7 @@ public void onFailure(Exception e) { final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - client.indices().getSettingsAsync(request, listener); + client.indices().getSettingsAsync(request, RequestOptions.DEFAULT, listener); assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -1009,7 +1010,7 @@ public void testForceMergeIndex() throws Exception { // end::force-merge-request-flush // tag::force-merge-execute - ForceMergeResponse forceMergeResponse = client.indices().forceMerge(request); + ForceMergeResponse forceMergeResponse = client.indices().forceMerge(request, RequestOptions.DEFAULT); // end::force-merge-execute // tag::force-merge-response @@ -1034,14 +1035,14 @@ public void onFailure(Exception e) { // end::force-merge-execute-listener // tag::force-merge-execute-async - client.indices().forceMergeAsync(request, listener); // <1> + client.indices().forceMergeAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::force-merge-execute-async } { // tag::force-merge-notfound try { ForceMergeRequest request = new ForceMergeRequest("does_not_exist"); - client.indices().forceMerge(request); + client.indices().forceMerge(request, RequestOptions.DEFAULT); } catch (ElasticsearchException exception) { if (exception.status() == RestStatus.NOT_FOUND) { // <1> @@ -1086,7 +1087,7 @@ public void testClearCache() throws Exception { // end::clear-cache-request-fields // tag::clear-cache-execute - ClearIndicesCacheResponse clearCacheResponse = client.indices().clearCache(request); + ClearIndicesCacheResponse clearCacheResponse = client.indices().clearCache(request, RequestOptions.DEFAULT); // end::clear-cache-execute // tag::clear-cache-response @@ -1115,7 +1116,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::clear-cache-execute-async - client.indices().clearCacheAsync(request, listener); // <1> + client.indices().clearCacheAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::clear-cache-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -1125,7 +1126,7 @@ public void onFailure(Exception e) { // tag::clear-cache-notfound try { ClearIndicesCacheRequest request = new ClearIndicesCacheRequest("does_not_exist"); - client.indices().clearCache(request); + client.indices().clearCache(request, RequestOptions.DEFAULT); } catch (ElasticsearchException exception) { if (exception.status() == RestStatus.NOT_FOUND) { // <1> @@ -1139,7 +1140,7 @@ public void testCloseIndex() throws Exception { RestHighLevelClient client = highLevelClient(); { - CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index")); + CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index"), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } @@ -1162,7 +1163,7 @@ public void testCloseIndex() throws Exception { // end::close-index-request-indicesOptions // tag::close-index-execute - CloseIndexResponse closeIndexResponse = client.indices().close(request); + CloseIndexResponse closeIndexResponse = client.indices().close(request, RequestOptions.DEFAULT); // end::close-index-execute // tag::close-index-response @@ -1190,7 +1191,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::close-index-execute-async - client.indices().closeAsync(request, listener); // <1> + client.indices().closeAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::close-index-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -1202,7 +1203,7 @@ public void testExistsAlias() throws Exception { { CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index") - .alias(new Alias("alias"))); + .alias(new Alias("alias")), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } @@ -1230,7 +1231,7 @@ public void testExistsAlias() throws Exception { // end::exists-alias-request-local // tag::exists-alias-execute - boolean exists = client.indices().existsAlias(request); + boolean exists = client.indices().existsAlias(request, RequestOptions.DEFAULT); // end::exists-alias-execute assertTrue(exists); @@ -1253,7 +1254,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::exists-alias-execute-async - client.indices().existsAliasAsync(request, listener); // <1> + client.indices().existsAliasAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::exists-alias-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -1264,13 +1265,13 @@ public void testUpdateAliases() throws Exception { RestHighLevelClient client = highLevelClient(); { - CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index1")); + CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index1"), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); - createIndexResponse = client.indices().create(new CreateIndexRequest("index2")); + createIndexResponse = client.indices().create(new CreateIndexRequest("index2"), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); - createIndexResponse = client.indices().create(new CreateIndexRequest("index3")); + createIndexResponse = client.indices().create(new CreateIndexRequest("index3"), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); - createIndexResponse = client.indices().create(new CreateIndexRequest("index4")); + createIndexResponse = client.indices().create(new CreateIndexRequest("index4"), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } @@ -1315,7 +1316,7 @@ public void testUpdateAliases() throws Exception { // tag::update-aliases-execute IndicesAliasesResponse indicesAliasesResponse = - client.indices().updateAliases(request); + client.indices().updateAliases(request, RequestOptions.DEFAULT); // end::update-aliases-execute // tag::update-aliases-response @@ -1349,7 +1350,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::update-aliases-execute-async - client.indices().updateAliasesAsync(request, listener); // <1> + client.indices().updateAliasesAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::update-aliases-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -1394,7 +1395,7 @@ public void testShrinkIndex() throws Exception { // end::shrink-index-request-aliases // tag::shrink-index-execute - ResizeResponse resizeResponse = client.indices().shrink(request); + ResizeResponse resizeResponse = client.indices().shrink(request, RequestOptions.DEFAULT); // end::shrink-index-execute // tag::shrink-index-response @@ -1423,7 +1424,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::shrink-index-execute-async - client.indices().shrinkAsync(request, listener); // <1> + client.indices().shrinkAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::shrink-index-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -1464,7 +1465,7 @@ public void testSplitIndex() throws Exception { // end::split-index-request-aliases // tag::split-index-execute - ResizeResponse resizeResponse = client.indices().split(request); + ResizeResponse resizeResponse = client.indices().split(request, RequestOptions.DEFAULT); // end::split-index-execute // tag::split-index-response @@ -1493,7 +1494,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::split-index-execute-async - client.indices().splitAsync(request,listener); // <1> + client.indices().splitAsync(request, RequestOptions.DEFAULT,listener); // <1> // end::split-index-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -1503,7 +1504,7 @@ public void testRolloverIndex() throws Exception { RestHighLevelClient client = highLevelClient(); { - client.indices().create(new CreateIndexRequest("index-1").alias(new Alias("alias"))); + client.indices().create(new CreateIndexRequest("index-1").alias(new Alias("alias")), RequestOptions.DEFAULT); } // tag::rollover-request @@ -1540,7 +1541,7 @@ public void testRolloverIndex() throws Exception { // end::rollover-request-alias // tag::rollover-execute - RolloverResponse rolloverResponse = client.indices().rollover(request); + RolloverResponse rolloverResponse = client.indices().rollover(request, RequestOptions.DEFAULT); // end::rollover-execute // tag::rollover-response @@ -1579,7 +1580,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::rollover-execute-async - client.indices().rolloverAsync(request,listener); // <1> + client.indices().rolloverAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::rollover-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -1589,7 +1590,7 @@ public void testIndexPutSettings() throws Exception { RestHighLevelClient client = highLevelClient(); { - CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index")); + CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index"), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } @@ -1652,7 +1653,7 @@ public void testIndexPutSettings() throws Exception { // tag::put-settings-execute UpdateSettingsResponse updateSettingsResponse = - client.indices().putSettings(request); + client.indices().putSettings(request, RequestOptions.DEFAULT); // end::put-settings-execute // tag::put-settings-response @@ -1681,7 +1682,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::put-settings-execute-async - client.indices().putSettingsAsync(request,listener); // <1> + client.indices().putSettingsAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::put-settings-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -1716,7 +1717,7 @@ public void testPutTemplate() throws Exception { "}", // <2> XContentType.JSON); // end::put-template-request-mappings-json - assertTrue(client.indices().putTemplate(request).isAcknowledged()); + assertTrue(client.indices().putTemplate(request, RequestOptions.DEFAULT).isAcknowledged()); } { //tag::put-template-request-mappings-map @@ -1730,7 +1731,7 @@ public void testPutTemplate() throws Exception { jsonMap.put("tweet", tweet); request.mapping("tweet", jsonMap); // <1> //end::put-template-request-mappings-map - assertTrue(client.indices().putTemplate(request).isAcknowledged()); + assertTrue(client.indices().putTemplate(request, RequestOptions.DEFAULT).isAcknowledged()); } { //tag::put-template-request-mappings-xcontent @@ -1754,13 +1755,13 @@ public void testPutTemplate() throws Exception { builder.endObject(); request.mapping("tweet", builder); // <1> //end::put-template-request-mappings-xcontent - assertTrue(client.indices().putTemplate(request).isAcknowledged()); + assertTrue(client.indices().putTemplate(request, RequestOptions.DEFAULT).isAcknowledged()); } { //tag::put-template-request-mappings-shortcut request.mapping("tweet", "message", "type=text"); // <1> //end::put-template-request-mappings-shortcut - assertTrue(client.indices().putTemplate(request).isAcknowledged()); + assertTrue(client.indices().putTemplate(request, RequestOptions.DEFAULT).isAcknowledged()); } // tag::put-template-request-aliases @@ -1814,7 +1815,7 @@ public void testPutTemplate() throws Exception { request.create(false); // make test happy // tag::put-template-execute - PutIndexTemplateResponse putTemplateResponse = client.indices().putTemplate(request); + PutIndexTemplateResponse putTemplateResponse = client.indices().putTemplate(request, RequestOptions.DEFAULT); // end::put-template-execute // tag::put-template-response @@ -1842,7 +1843,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::put-template-execute-async - client.indices().putTemplateAsync(request, listener); // <1> + client.indices().putTemplateAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::put-template-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IngestClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IngestClientDocumentationIT.java index 7971e49da44f4..f5bdc9f2f3ee5 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IngestClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IngestClientDocumentationIT.java @@ -27,6 +27,7 @@ import org.elasticsearch.action.ingest.PutPipelineRequest; import org.elasticsearch.action.ingest.WritePipelineResponse; import org.elasticsearch.client.ESRestHighLevelClientTestCase; +import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.unit.TimeValue; @@ -86,7 +87,7 @@ public void testPutPipeline() throws IOException { // end::put-pipeline-request-masterTimeout // tag::put-pipeline-execute - WritePipelineResponse response = client.ingest().putPipeline(request); // <1> + WritePipelineResponse response = client.ingest().putPipeline(request, RequestOptions.DEFAULT); // <1> // end::put-pipeline-execute // tag::put-pipeline-response @@ -129,7 +130,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::put-pipeline-execute-async - client.ingest().putPipelineAsync(request, listener); // <1> + client.ingest().putPipelineAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::put-pipeline-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -154,7 +155,7 @@ public void testGetPipeline() throws IOException { // end::get-pipeline-request-masterTimeout // tag::get-pipeline-execute - GetPipelineResponse response = client.ingest().getPipeline(request); // <1> + GetPipelineResponse response = client.ingest().getPipeline(request, RequestOptions.DEFAULT); // <1> // end::get-pipeline-execute // tag::get-pipeline-response @@ -199,7 +200,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::get-pipeline-execute-async - client.ingest().getPipelineAsync(request, listener); // <1> + client.ingest().getPipelineAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::get-pipeline-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -229,7 +230,7 @@ public void testDeletePipeline() throws IOException { // end::delete-pipeline-request-masterTimeout // tag::delete-pipeline-execute - WritePipelineResponse response = client.ingest().deletePipeline(request); // <1> + WritePipelineResponse response = client.ingest().deletePipeline(request, RequestOptions.DEFAULT); // <1> // end::delete-pipeline-execute // tag::delete-pipeline-response @@ -269,7 +270,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::delete-pipeline-execute-async - client.ingest().deletePipelineAsync(request, listener); // <1> + client.ingest().deletePipelineAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::delete-pipeline-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MigrationDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MigrationDocumentationIT.java index 489d4d9b1ed5f..b56fb3359ffae 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MigrationDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MigrationDocumentationIT.java @@ -19,10 +19,6 @@ package org.elasticsearch.client.documentation; -import org.apache.http.HttpEntity; -import org.apache.http.HttpStatus; -import org.apache.http.entity.ContentType; -import org.apache.http.nio.entity.NStringEntity; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.delete.DeleteResponse; @@ -31,12 +27,10 @@ import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.client.ESRestHighLevelClientTestCase; import org.elasticsearch.client.Request; +import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.Response; import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.cluster.health.ClusterHealthStatus; -import org.elasticsearch.common.Strings; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.rest.RestStatus; @@ -45,11 +39,6 @@ import java.io.InputStream; import java.util.Map; -import static java.util.Collections.emptyMap; -import static java.util.Collections.singletonMap; -import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; -import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; - /** * This class is used to generate the documentation for the * docs/java-rest/high-level/migration.asciidoc page. @@ -98,14 +87,14 @@ public void testRequests() throws Exception { //end::migration-request-ctor //tag::migration-request-ctor-execution - IndexResponse response = client.index(request); + IndexResponse response = client.index(request, RequestOptions.DEFAULT); //end::migration-request-ctor-execution assertEquals(RestStatus.CREATED, response.status()); } { //tag::migration-request-async-execution DeleteRequest request = new DeleteRequest("index", "doc", "id"); // <1> - client.deleteAsync(request, new ActionListener() { // <2> + client.deleteAsync(request, RequestOptions.DEFAULT, new ActionListener() { // <2> @Override public void onResponse(DeleteResponse deleteResponse) { // <3> @@ -117,12 +106,12 @@ public void onFailure(Exception e) { } }); //end::migration-request-async-execution - assertBusy(() -> assertFalse(client.exists(new GetRequest("index", "doc", "id")))); + assertBusy(() -> assertFalse(client.exists(new GetRequest("index", "doc", "id"), RequestOptions.DEFAULT))); } { //tag::migration-request-sync-execution DeleteRequest request = new DeleteRequest("index", "doc", "id"); - DeleteResponse response = client.delete(request); // <1> + DeleteResponse response = client.delete(request, RequestOptions.DEFAULT); // <1> //end::migration-request-sync-execution assertEquals(RestStatus.NOT_FOUND, response.status()); } diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MiscellaneousDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MiscellaneousDocumentationIT.java index 504ea797c35f6..2186bd8ebfd30 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MiscellaneousDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MiscellaneousDocumentationIT.java @@ -24,6 +24,7 @@ import org.elasticsearch.Version; import org.elasticsearch.action.main.MainResponse; import org.elasticsearch.client.ESRestHighLevelClientTestCase; +import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.cluster.ClusterName; @@ -40,7 +41,7 @@ public void testMain() throws IOException { RestHighLevelClient client = highLevelClient(); { //tag::main-execute - MainResponse response = client.info(); + MainResponse response = client.info(RequestOptions.DEFAULT); //end::main-execute //tag::main-response ClusterName clusterName = response.getClusterName(); // <1> @@ -60,7 +61,7 @@ public void testMain() throws IOException { public void testPing() throws IOException { RestHighLevelClient client = highLevelClient(); //tag::ping-execute - boolean response = client.ping(); + boolean response = client.ping(RequestOptions.DEFAULT); //end::ping-execute assertTrue(response); } 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 463c5f7d12f5e..cf6409bab6444 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 @@ -42,6 +42,7 @@ import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.client.ESRestHighLevelClientTestCase; import org.elasticsearch.client.Request; +import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.Response; import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestHighLevelClient; @@ -143,7 +144,7 @@ public void testSearch() throws Exception { // tag::search-request-preference searchRequest.preference("_local"); // <1> // end::search-request-preference - assertNotNull(client.search(searchRequest)); + assertNotNull(client.search(searchRequest, RequestOptions.DEFAULT)); } { // tag::search-source-basics @@ -176,7 +177,7 @@ public void testSearch() throws Exception { // end::search-source-setter // tag::search-execute - SearchResponse searchResponse = client.search(searchRequest); + SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT); // end::search-execute // tag::search-execute-listener @@ -198,7 +199,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::search-execute-async - client.searchAsync(searchRequest, listener); // <1> + client.searchAsync(searchRequest, RequestOptions.DEFAULT, listener); // <1> // end::search-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -296,7 +297,7 @@ public void testSearchRequestAggregations() throws IOException { request.add(new IndexRequest("posts", "doc", "3") .source(XContentType.JSON, "company", "Elastic", "age", 40)); request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); - BulkResponse bulkResponse = client.bulk(request); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); assertSame(RestStatus.OK, bulkResponse.status()); assertFalse(bulkResponse.hasFailures()); } @@ -312,7 +313,7 @@ public void testSearchRequestAggregations() throws IOException { // end::search-request-aggregations searchSourceBuilder.query(QueryBuilders.matchAllQuery()); searchRequest.source(searchSourceBuilder); - SearchResponse searchResponse = client.search(searchRequest); + SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT); { // tag::search-request-aggregations-get Aggregations aggregations = searchResponse.getAggregations(); @@ -369,7 +370,7 @@ public void testSearchRequestSuggestions() throws IOException { request.add(new IndexRequest("posts", "doc", "3").source(XContentType.JSON, "user", "tlrx")); request.add(new IndexRequest("posts", "doc", "4").source(XContentType.JSON, "user", "cbuescher")); request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); - BulkResponse bulkResponse = client.bulk(request); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); assertSame(RestStatus.OK, bulkResponse.status()); assertFalse(bulkResponse.hasFailures()); } @@ -384,7 +385,7 @@ public void testSearchRequestSuggestions() throws IOException { searchSourceBuilder.suggest(suggestBuilder); // end::search-request-suggestion searchRequest.source(searchSourceBuilder); - SearchResponse searchResponse = client.search(searchRequest); + SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT); { // tag::search-request-suggestion-get Suggest suggest = searchResponse.getSuggest(); // <1> @@ -416,7 +417,7 @@ public void testSearchRequestHighlighting() throws IOException { .source(XContentType.JSON, "title", "The Future of Federated Search in Elasticsearch", "user", Arrays.asList("kimchy", "tanguy"), "innerObject", Collections.singletonMap("key", "value"))); request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); - BulkResponse bulkResponse = client.bulk(request); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); assertSame(RestStatus.OK, bulkResponse.status()); assertFalse(bulkResponse.hasFailures()); } @@ -437,7 +438,7 @@ public void testSearchRequestHighlighting() throws IOException { .should(matchQuery("title", "Elasticsearch")) .should(matchQuery("user", "kimchy"))); searchRequest.source(searchSourceBuilder); - SearchResponse searchResponse = client.search(searchRequest); + SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT); { // tag::search-request-highlighting-get SearchHits hits = searchResponse.getHits(); @@ -472,7 +473,7 @@ public void testSearchRequestProfiling() throws IOException { IndexRequest request = new IndexRequest("posts", "doc", "1") .source(XContentType.JSON, "tags", "elasticsearch", "comments", 123); request.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL); - IndexResponse indexResponse = client.index(request); + IndexResponse indexResponse = client.index(request, RequestOptions.DEFAULT); assertSame(RestStatus.CREATED, indexResponse.status()); } { @@ -485,7 +486,7 @@ public void testSearchRequestProfiling() throws IOException { searchSourceBuilder.aggregation(AggregationBuilders.histogram("by_comments").field("comments").interval(100)); searchRequest.source(searchSourceBuilder); - SearchResponse searchResponse = client.search(searchRequest); + SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT); // tag::search-request-profiling-get Map profilingResults = searchResponse.getProfileResults(); // <1> @@ -548,7 +549,7 @@ public void testScroll() throws Exception { request.add(new IndexRequest("posts", "doc", "3") .source(XContentType.JSON, "title", "The Future of Federated Search in Elasticsearch")); request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); - BulkResponse bulkResponse = client.bulk(request); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); assertSame(RestStatus.OK, bulkResponse.status()); assertFalse(bulkResponse.hasFailures()); } @@ -561,7 +562,7 @@ public void testScroll() throws Exception { searchSourceBuilder.size(size); // <1> searchRequest.source(searchSourceBuilder); searchRequest.scroll(TimeValue.timeValueMinutes(1L)); // <2> - SearchResponse searchResponse = client.search(searchRequest); + SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT); String scrollId = searchResponse.getScrollId(); // <3> SearchHits hits = searchResponse.getHits(); // <4> // end::search-scroll-init @@ -572,7 +573,7 @@ public void testScroll() throws Exception { // tag::search-scroll2 SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId); // <1> scrollRequest.scroll(TimeValue.timeValueSeconds(30)); - SearchResponse searchScrollResponse = client.searchScroll(scrollRequest); + SearchResponse searchScrollResponse = client.searchScroll(scrollRequest, RequestOptions.DEFAULT); scrollId = searchScrollResponse.getScrollId(); // <2> hits = searchScrollResponse.getHits(); // <3> assertEquals(3, hits.getTotalHits()); @@ -582,14 +583,14 @@ public void testScroll() throws Exception { ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); clearScrollRequest.addScrollId(scrollId); - ClearScrollResponse clearScrollResponse = client.clearScroll(clearScrollRequest); + ClearScrollResponse clearScrollResponse = client.clearScroll(clearScrollRequest, RequestOptions.DEFAULT); assertTrue(clearScrollResponse.isSucceeded()); } { SearchRequest searchRequest = new SearchRequest(); searchRequest.scroll("60s"); - SearchResponse initialSearchResponse = client.search(searchRequest); + SearchResponse initialSearchResponse = client.search(searchRequest, RequestOptions.DEFAULT); String scrollId = initialSearchResponse.getScrollId(); SearchScrollRequest scrollRequest = new SearchScrollRequest(); @@ -601,7 +602,7 @@ public void testScroll() throws Exception { // end::scroll-request-arguments // tag::search-scroll-execute-sync - SearchResponse searchResponse = client.searchScroll(scrollRequest); + SearchResponse searchResponse = client.searchScroll(scrollRequest, RequestOptions.DEFAULT); // end::search-scroll-execute-sync assertEquals(0, searchResponse.getFailedShards()); @@ -648,7 +649,7 @@ public void onFailure(Exception e) { // end::clear-scroll-add-scroll-ids // tag::clear-scroll-execute - ClearScrollResponse response = client.clearScroll(request); + ClearScrollResponse response = client.clearScroll(request, RequestOptions.DEFAULT); // end::clear-scroll-execute // tag::clear-scroll-response @@ -678,7 +679,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, clearScrollLatch); // tag::clear-scroll-execute-async - client.clearScrollAsync(request, listener); // <1> + client.clearScrollAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::clear-scroll-execute-async assertTrue(clearScrollLatch.await(30L, TimeUnit.SECONDS)); @@ -692,14 +693,14 @@ public void onFailure(Exception e) { searchSourceBuilder.query(matchQuery("title", "Elasticsearch")); searchRequest.source(searchSourceBuilder); - SearchResponse searchResponse = client.search(searchRequest); // <1> + SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT); // <1> String scrollId = searchResponse.getScrollId(); SearchHit[] searchHits = searchResponse.getHits().getHits(); while (searchHits != null && searchHits.length > 0) { // <2> SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId); // <3> scrollRequest.scroll(scroll); - searchResponse = client.searchScroll(scrollRequest); + searchResponse = client.searchScroll(scrollRequest, RequestOptions.DEFAULT); scrollId = searchResponse.getScrollId(); searchHits = searchResponse.getHits().getHits(); // <4> @@ -707,7 +708,7 @@ public void onFailure(Exception e) { ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); // <5> clearScrollRequest.addScrollId(scrollId); - ClearScrollResponse clearScrollResponse = client.clearScroll(clearScrollRequest); + ClearScrollResponse clearScrollResponse = client.clearScroll(clearScrollRequest, RequestOptions.DEFAULT); boolean succeeded = clearScrollResponse.isSucceeded(); // end::search-scroll-example assertTrue(succeeded); @@ -737,7 +738,7 @@ public void testSearchTemplateWithInlineScript() throws Exception { // end::search-template-request-inline // tag::search-template-response - SearchTemplateResponse response = client.searchTemplate(request); + SearchTemplateResponse response = client.searchTemplate(request, RequestOptions.DEFAULT); SearchResponse searchResponse = response.getResponse(); // end::search-template-response @@ -749,7 +750,7 @@ public void testSearchTemplateWithInlineScript() throws Exception { // end::render-search-template-request // tag::render-search-template-response - SearchTemplateResponse renderResponse = client.searchTemplate(request); + SearchTemplateResponse renderResponse = client.searchTemplate(request, RequestOptions.DEFAULT); BytesReference source = renderResponse.getSource(); // <1> // end::render-search-template-response @@ -802,7 +803,7 @@ public void testSearchTemplateWithStoredScript() throws Exception { // end::search-template-request-options // tag::search-template-execute - SearchTemplateResponse response = client.searchTemplate(request); + SearchTemplateResponse response = client.searchTemplate(request, RequestOptions.DEFAULT); // end::search-template-execute SearchResponse searchResponse = response.getResponse(); @@ -828,7 +829,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::search-template-execute-async - client.searchTemplateAsync(request, listener); // <1> + client.searchTemplateAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::search-template-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -849,7 +850,7 @@ public void testFieldCaps() throws Exception { // end::field-caps-request-indicesOptions // tag::field-caps-execute - FieldCapabilitiesResponse response = client.fieldCaps(request); + FieldCapabilitiesResponse response = client.fieldCaps(request, RequestOptions.DEFAULT); // end::field-caps-execute // tag::field-caps-response @@ -892,7 +893,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::field-caps-execute-async - client.fieldCapsAsync(request, listener); // <1> + client.fieldCapsAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::field-caps-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -918,7 +919,7 @@ public void testRankEval() throws Exception { // end::rank-eval-request-basic // tag::rank-eval-execute - RankEvalResponse response = client.rankEval(request); + RankEvalResponse response = client.rankEval(request, RequestOptions.DEFAULT); // end::rank-eval-execute // tag::rank-eval-response @@ -962,7 +963,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::rank-eval-execute-async - client.rankEvalAsync(request, listener); // <1> + client.rankEvalAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::rank-eval-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -987,7 +988,7 @@ public void testMultiSearch() throws Exception { request.add(secondSearchRequest); // end::multi-search-request-basic // tag::multi-search-execute - MultiSearchResponse response = client.multiSearch(request); + MultiSearchResponse response = client.multiSearch(request, RequestOptions.DEFAULT); // end::multi-search-execute // tag::multi-search-response MultiSearchResponse.Item firstResponse = response.getResponses()[0]; // <1> @@ -1019,7 +1020,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::multi-search-execute-async - client.multiSearchAsync(request, listener); // <1> + client.multiSearchAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::multi-search-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -1030,7 +1031,7 @@ public void onFailure(Exception e) { request.add(new SearchRequest("posts") // <1> .types("doc")); // <2> // end::multi-search-request-index - MultiSearchResponse response = client.multiSearch(request); + MultiSearchResponse response = client.multiSearch(request, RequestOptions.DEFAULT); MultiSearchResponse.Item firstResponse = response.getResponses()[0]; assertNull(firstResponse.getFailure()); SearchResponse searchResponse = firstResponse.getResponse(); @@ -1041,12 +1042,12 @@ public void onFailure(Exception e) { private void indexSearchTestData() throws IOException { CreateIndexRequest authorsRequest = new CreateIndexRequest("authors") .mapping("doc", "user", "type=keyword,doc_values=false"); - CreateIndexResponse authorsResponse = highLevelClient().indices().create(authorsRequest); + CreateIndexResponse authorsResponse = highLevelClient().indices().create(authorsRequest, RequestOptions.DEFAULT); assertTrue(authorsResponse.isAcknowledged()); CreateIndexRequest reviewersRequest = new CreateIndexRequest("contributors") .mapping("doc", "user", "type=keyword"); - CreateIndexResponse reviewersResponse = highLevelClient().indices().create(reviewersRequest); + CreateIndexResponse reviewersResponse = highLevelClient().indices().create(reviewersRequest, RequestOptions.DEFAULT); assertTrue(reviewersResponse.isAcknowledged()); BulkRequest bulkRequest = new BulkRequest(); @@ -1067,7 +1068,7 @@ private void indexSearchTestData() throws IOException { bulkRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); - BulkResponse bulkResponse = highLevelClient().bulk(bulkRequest); + BulkResponse bulkResponse = highLevelClient().bulk(bulkRequest, RequestOptions.DEFAULT); assertSame(RestStatus.OK, bulkResponse.status()); assertFalse(bulkResponse.hasFailures()); } diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SnapshotClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SnapshotClientDocumentationIT.java index 2890ad50c2666..8c158a91a5111 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SnapshotClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SnapshotClientDocumentationIT.java @@ -30,6 +30,7 @@ import org.elasticsearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest; import org.elasticsearch.action.admin.cluster.repositories.verify.VerifyRepositoryResponse; import org.elasticsearch.client.ESRestHighLevelClientTestCase; +import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.cluster.metadata.RepositoryMetaData; import org.elasticsearch.common.settings.Settings; @@ -134,7 +135,7 @@ public void testSnapshotCreateRepository() throws IOException { // end::create-repository-request-verify // tag::create-repository-execute - PutRepositoryResponse response = client.snapshot().createRepository(request); + PutRepositoryResponse response = client.snapshot().createRepository(request, RequestOptions.DEFAULT); // end::create-repository-execute // tag::create-repository-response @@ -168,7 +169,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::create-repository-execute-async - client.snapshot().createRepositoryAsync(request, listener); // <1> + client.snapshot().createRepositoryAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::create-repository-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -197,7 +198,7 @@ public void testSnapshotGetRepository() throws IOException { // end::get-repository-request-masterTimeout // tag::get-repository-execute - GetRepositoriesResponse response = client.snapshot().getRepositories(request); + GetRepositoriesResponse response = client.snapshot().getRepositories(request, RequestOptions.DEFAULT); // end::get-repository-execute // tag::get-repository-response @@ -232,7 +233,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::get-repository-execute-async - client.snapshot().getRepositoriesAsync(request, listener); // <1> + client.snapshot().getRepositoriesAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::get-repository-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -258,7 +259,7 @@ public void testSnapshotDeleteRepository() throws IOException { // end::delete-repository-request-timeout // tag::delete-repository-execute - DeleteRepositoryResponse response = client.snapshot().deleteRepository(request); + DeleteRepositoryResponse response = client.snapshot().deleteRepository(request, RequestOptions.DEFAULT); // end::delete-repository-execute // tag::delete-repository-response @@ -292,7 +293,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::delete-repository-execute-async - client.snapshot().deleteRepositoryAsync(request, listener); // <1> + client.snapshot().deleteRepositoryAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::delete-repository-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -317,7 +318,7 @@ public void testSnapshotVerifyRepository() throws IOException { // end::verify-repository-request-timeout // tag::verify-repository-execute - VerifyRepositoryResponse response = client.snapshot().verifyRepository(request); + VerifyRepositoryResponse response = client.snapshot().verifyRepository(request, RequestOptions.DEFAULT); // end::verify-repository-execute // tag::verify-repository-response @@ -352,7 +353,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::verify-repository-execute-async - client.snapshot().verifyRepositoryAsync(request, listener); // <1> + client.snapshot().verifyRepositoryAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::verify-repository-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -363,6 +364,6 @@ private void createTestRepositories() throws IOException { PutRepositoryRequest request = new PutRepositoryRequest(repositoryName); request.type(FsRepository.TYPE); request.settings("{\"location\": \".\"}", XContentType.JSON); - assertTrue(highLevelClient().snapshot().createRepository(request).isAcknowledged()); + assertTrue(highLevelClient().snapshot().createRepository(request, RequestOptions.DEFAULT).isAcknowledged()); } } diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/TasksClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/TasksClientDocumentationIT.java index faf447a4143b1..0d62a2d29a03b 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/TasksClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/TasksClientDocumentationIT.java @@ -27,6 +27,7 @@ import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse; import org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup; import org.elasticsearch.client.ESRestHighLevelClientTestCase; +import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.tasks.TaskId; @@ -90,7 +91,7 @@ public void testListTasks() throws IOException { ListTasksRequest request = new ListTasksRequest(); // tag::list-tasks-execute - ListTasksResponse response = client.tasks().list(request); + ListTasksResponse response = client.tasks().list(request, RequestOptions.DEFAULT); // end::list-tasks-execute assertThat(response, notNullValue()); @@ -139,7 +140,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::list-tasks-execute-async - client.tasks().listAsync(request, listener); // <1> + client.tasks().listAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::list-tasks-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); diff --git a/qa/ccs-unavailable-clusters/src/test/java/org/elasticsearch/search/CrossClusterSearchUnavailableClusterIT.java b/qa/ccs-unavailable-clusters/src/test/java/org/elasticsearch/search/CrossClusterSearchUnavailableClusterIT.java index f7b87905b24d5..73df782c92049 100644 --- a/qa/ccs-unavailable-clusters/src/test/java/org/elasticsearch/search/CrossClusterSearchUnavailableClusterIT.java +++ b/qa/ccs-unavailable-clusters/src/test/java/org/elasticsearch/search/CrossClusterSearchUnavailableClusterIT.java @@ -36,6 +36,7 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchScrollRequest; import org.elasticsearch.client.Request; +import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.Response; import org.elasticsearch.client.ResponseException; import org.elasticsearch.client.RestClient; @@ -133,19 +134,20 @@ public void testSearchSkipUnavailable() throws IOException { updateRemoteClusterSettings(Collections.singletonMap("seeds", remoteNode.getAddress().toString())); for (int i = 0; i < 10; i++) { - restHighLevelClient.index(new IndexRequest("index", "doc", String.valueOf(i)).source("field", "value")); + restHighLevelClient.index( + new IndexRequest("index", "doc", String.valueOf(i)).source("field", "value"), RequestOptions.DEFAULT); } Response refreshResponse = client().performRequest(new Request("POST", "/index/_refresh")); assertEquals(200, refreshResponse.getStatusLine().getStatusCode()); { - SearchResponse response = restHighLevelClient.search(new SearchRequest("index")); + SearchResponse response = restHighLevelClient.search(new SearchRequest("index"), RequestOptions.DEFAULT); assertSame(SearchResponse.Clusters.EMPTY, response.getClusters()); assertEquals(10, response.getHits().totalHits); assertEquals(10, response.getHits().getHits().length); } { - SearchResponse response = restHighLevelClient.search(new SearchRequest("index", "remote1:index")); + SearchResponse response = restHighLevelClient.search(new SearchRequest("index", "remote1:index"), RequestOptions.DEFAULT); assertEquals(2, response.getClusters().getTotal()); assertEquals(2, response.getClusters().getSuccessful()); assertEquals(0, response.getClusters().getSkipped()); @@ -153,7 +155,7 @@ public void testSearchSkipUnavailable() throws IOException { assertEquals(10, response.getHits().getHits().length); } { - SearchResponse response = restHighLevelClient.search(new SearchRequest("remote1:index")); + SearchResponse response = restHighLevelClient.search(new SearchRequest("remote1:index"), RequestOptions.DEFAULT); assertEquals(1, response.getClusters().getTotal()); assertEquals(1, response.getClusters().getSuccessful()); assertEquals(0, response.getClusters().getSkipped()); @@ -161,14 +163,15 @@ public void testSearchSkipUnavailable() throws IOException { } { - SearchResponse response = restHighLevelClient.search(new SearchRequest("index", "remote1:index").scroll("1m")); + SearchResponse response = restHighLevelClient.search(new SearchRequest("index", "remote1:index").scroll("1m"), + RequestOptions.DEFAULT); assertEquals(2, response.getClusters().getTotal()); assertEquals(2, response.getClusters().getSuccessful()); assertEquals(0, response.getClusters().getSkipped()); assertEquals(10, response.getHits().totalHits); assertEquals(10, response.getHits().getHits().length); String scrollId = response.getScrollId(); - SearchResponse scrollResponse = restHighLevelClient.searchScroll(new SearchScrollRequest(scrollId)); + SearchResponse scrollResponse = restHighLevelClient.searchScroll(new SearchScrollRequest(scrollId), RequestOptions.DEFAULT); assertSame(SearchResponse.Clusters.EMPTY, scrollResponse.getClusters()); assertEquals(10, scrollResponse.getHits().totalHits); assertEquals(0, scrollResponse.getHits().getHits().length); @@ -179,7 +182,7 @@ public void testSearchSkipUnavailable() throws IOException { updateRemoteClusterSettings(Collections.singletonMap("skip_unavailable", true)); { - SearchResponse response = restHighLevelClient.search(new SearchRequest("index", "remote1:index")); + SearchResponse response = restHighLevelClient.search(new SearchRequest("index", "remote1:index"), RequestOptions.DEFAULT); assertEquals(2, response.getClusters().getTotal()); assertEquals(1, response.getClusters().getSuccessful()); assertEquals(1, response.getClusters().getSkipped()); @@ -187,7 +190,7 @@ public void testSearchSkipUnavailable() throws IOException { assertEquals(10, response.getHits().getHits().length); } { - SearchResponse response = restHighLevelClient.search(new SearchRequest("remote1:index")); + SearchResponse response = restHighLevelClient.search(new SearchRequest("remote1:index"), RequestOptions.DEFAULT); assertEquals(1, response.getClusters().getTotal()); assertEquals(0, response.getClusters().getSuccessful()); assertEquals(1, response.getClusters().getSkipped()); @@ -195,14 +198,15 @@ public void testSearchSkipUnavailable() throws IOException { } { - SearchResponse response = restHighLevelClient.search(new SearchRequest("index", "remote1:index").scroll("1m")); + SearchResponse response = restHighLevelClient.search(new SearchRequest("index", "remote1:index").scroll("1m"), + RequestOptions.DEFAULT); assertEquals(2, response.getClusters().getTotal()); assertEquals(1, response.getClusters().getSuccessful()); assertEquals(1, response.getClusters().getSkipped()); assertEquals(10, response.getHits().totalHits); assertEquals(10, response.getHits().getHits().length); String scrollId = response.getScrollId(); - SearchResponse scrollResponse = restHighLevelClient.searchScroll(new SearchScrollRequest(scrollId)); + SearchResponse scrollResponse = restHighLevelClient.searchScroll(new SearchScrollRequest(scrollId), RequestOptions.DEFAULT); assertSame(SearchResponse.Clusters.EMPTY, scrollResponse.getClusters()); assertEquals(10, scrollResponse.getHits().totalHits); assertEquals(0, scrollResponse.getHits().getHits().length); @@ -266,19 +270,19 @@ public void testSkipUnavailableDependsOnSeeds() throws IOException { private static void assertSearchConnectFailure() { { ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> restHighLevelClient.search(new SearchRequest("index", "remote1:index"))); + () -> restHighLevelClient.search(new SearchRequest("index", "remote1:index"), RequestOptions.DEFAULT)); ElasticsearchException rootCause = (ElasticsearchException)exception.getRootCause(); assertThat(rootCause.getMessage(), containsString("connect_exception")); } { ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> restHighLevelClient.search(new SearchRequest("remote1:index"))); + () -> restHighLevelClient.search(new SearchRequest("remote1:index"), RequestOptions.DEFAULT)); ElasticsearchException rootCause = (ElasticsearchException)exception.getRootCause(); assertThat(rootCause.getMessage(), containsString("connect_exception")); } { ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> restHighLevelClient.search(new SearchRequest("remote1:index").scroll("1m"))); + () -> restHighLevelClient.search(new SearchRequest("remote1:index").scroll("1m"), RequestOptions.DEFAULT)); ElasticsearchException rootCause = (ElasticsearchException)exception.getRootCause(); assertThat(rootCause.getMessage(), containsString("connect_exception")); } From caf3bfc1da1ecbf7fdbdb7162a48dfe39fc4beef Mon Sep 17 00:00:00 2001 From: javanna Date: Mon, 4 Jun 2018 19:25:52 +0200 Subject: [PATCH 2/7] iter --- .../main/java/org/elasticsearch/client/IndicesClient.java | 1 + .../java/org/elasticsearch/client/RequestConverters.java | 2 +- .../org/elasticsearch/client/RestHighLevelClient.java | 1 + .../src/test/java/org/elasticsearch/client/CrudIT.java | 8 ++++---- .../documentation/IndicesClientDocumentationIT.java | 6 ++++-- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java index afc09292c4601..009d5f309030c 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java @@ -498,6 +498,7 @@ public void flushAsync(FlushRequest flushRequest, RequestOptions options, Action * See Flush API on elastic.co * @deprecated Prefer {@link #flushAsync(FlushRequest, RequestOptions, ActionListener)} */ + @Deprecated public void flushAsync(FlushRequest flushRequest, ActionListener listener, Header... headers) { restHighLevelClient.performRequestAsyncAndParseEntity(flushRequest, RequestConverters::flush, FlushResponse::fromXContent, listener, emptySet(), headers); diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java index 6c8bb845259e6..009f08ee8740c 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java @@ -696,7 +696,7 @@ static Request rollover(RolloverRequest rolloverRequest) throws IOException { return request; } - static Request getSettings(GetSettingsRequest getSettingsRequest) throws IOException { + static Request getSettings(GetSettingsRequest getSettingsRequest) { String[] indices = getSettingsRequest.indices() == null ? Strings.EMPTY_ARRAY : getSettingsRequest.indices(); String[] names = getSettingsRequest.names() == null ? Strings.EMPTY_ARRAY : getSettingsRequest.names(); 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 0613cc6f10727..e998b69c66c5c 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 @@ -701,6 +701,7 @@ public final void multiSearchAsync(MultiSearchRequest searchRequest, RequestOpti * 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); 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 6177dea4a184e..81c894f242fe4 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 @@ -110,8 +110,8 @@ public void testDelete() throws IOException { // Testing version type String docId = "version_type"; highLevelClient().index( - new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar"), RequestOptions.DEFAULT) - .versionType(VersionType.EXTERNAL).version(12)); + 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); @@ -124,8 +124,8 @@ public void testDelete() throws IOException { // Testing version type with a wrong version String docId = "wrong_version"; highLevelClient().index( - new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar"), RequestOptions.DEFAULT) - .versionType(VersionType.EXTERNAL).version(12)); + new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar")) + .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, 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 4f36d028a1905..83e18c53910dd 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 @@ -871,7 +871,8 @@ public void testGetSettings() throws Exception { { Settings settings = Settings.builder().put("number_of_shards", 3).build(); - CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index", settings), RequestOptions.DEFAULT); + CreateIndexResponse createIndexResponse = client.indices().create( + new CreateIndexRequest("index", settings), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } @@ -934,7 +935,8 @@ public void testGetSettingsWithDefaults() throws Exception { { Settings settings = Settings.builder().put("number_of_shards", 3).build(); - CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index", settings), RequestOptions.DEFAULT); + CreateIndexResponse createIndexResponse = client.indices().create( + new CreateIndexRequest("index", settings), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } From 2347cdfa7680b918bb6d65457a6eb469d725de53 Mon Sep 17 00:00:00 2001 From: javanna Date: Mon, 4 Jun 2018 21:32:27 +0200 Subject: [PATCH 3/7] address comment --- .../src/main/java/org/elasticsearch/client/IndicesClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java index 009d5f309030c..c2ed8dbac12dd 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java @@ -903,7 +903,7 @@ public void putSettingsAsync(UpdateSettingsRequest updateSettingsRequest, Reques *

* See Update Indices Settings * API on elastic.co - * @deprecated Prefer {@link #putMappingAsync(PutMappingRequest, RequestOptions, ActionListener)} + * @deprecated Prefer {@link #putSettingsAsync(UpdateSettingsRequest, RequestOptions, ActionListener)} */ @Deprecated public void putSettingsAsync(UpdateSettingsRequest updateSettingsRequest, ActionListener listener, From 53be62ba8df30dacc0689379b1ad47ae19cb46ee Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 6 Jun 2018 12:41:10 +0200 Subject: [PATCH 4/7] add @param tags to javadocs --- .../elasticsearch/client/ClusterClient.java | 9 +- .../elasticsearch/client/IndicesClient.java | 214 +++++++++++++----- .../elasticsearch/client/IngestClient.java | 27 ++- .../client/RestHighLevelClient.java | 133 ++++++++--- .../elasticsearch/client/SnapshotClient.java | 36 ++- .../org/elasticsearch/client/TasksClient.java | 9 +- 6 files changed, 322 insertions(+), 106 deletions(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java index 768d5668282ea..202e0d4035afc 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java @@ -42,9 +42,12 @@ public final class ClusterClient { /** * Updates cluster wide specific settings using the Cluster Update Settings API - *

* See Cluster Update Settings * API on elastic.co + * @param clusterUpdateSettingsRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public ClusterUpdateSettingsResponse putSettings(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest, RequestOptions options) throws IOException { @@ -68,9 +71,11 @@ public ClusterUpdateSettingsResponse putSettings(ClusterUpdateSettingsRequest cl /** * Asynchronously updates cluster wide specific settings using the Cluster Update Settings API - *

* See Cluster Update Settings * API on elastic.co + * @param clusterUpdateSettingsRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void putSettingsAsync(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest, RequestOptions options, ActionListener listener) { diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java index 08f2e08d05505..43484702c946e 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java @@ -20,7 +20,6 @@ package org.elasticsearch.client; import org.apache.http.Header; -import org.elasticsearch.action.Action; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; @@ -47,10 +46,10 @@ import org.elasticsearch.action.admin.indices.open.OpenIndexResponse; import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; -import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; -import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse; import org.elasticsearch.action.admin.indices.rollover.RolloverRequest; import org.elasticsearch.action.admin.indices.rollover.RolloverResponse; +import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; +import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse; import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest; import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsResponse; import org.elasticsearch.action.admin.indices.shrink.ResizeRequest; @@ -77,9 +76,12 @@ public final class IndicesClient { /** * Deletes an index using the Delete Index API - *

* See * Delete Index API on elastic.co + * @param deleteIndexRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public DeleteIndexResponse delete(DeleteIndexRequest deleteIndexRequest, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity(deleteIndexRequest, RequestConverters::deleteIndex, options, @@ -101,9 +103,11 @@ public DeleteIndexResponse delete(DeleteIndexRequest deleteIndexRequest, Header. /** * Asynchronously deletes an index using the Delete Index API - *

* See * Delete Index API on elastic.co + * @param deleteIndexRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void deleteAsync(DeleteIndexRequest deleteIndexRequest, RequestOptions options, ActionListener listener) { restHighLevelClient.performRequestAsyncAndParseEntity(deleteIndexRequest, RequestConverters::deleteIndex, options, @@ -125,9 +129,12 @@ public void deleteAsync(DeleteIndexRequest deleteIndexRequest, ActionListener * See * Create Index API on elastic.co + * @param createIndexRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public CreateIndexResponse create(CreateIndexRequest createIndexRequest, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity(createIndexRequest, RequestConverters::createIndex, options, @@ -149,9 +156,11 @@ public CreateIndexResponse create(CreateIndexRequest createIndexRequest, Header. /** * Asynchronously creates an index using the Create Index API - *

* See * Create Index API on elastic.co + * @param createIndexRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void createAsync(CreateIndexRequest createIndexRequest, RequestOptions options, ActionListener listener) { restHighLevelClient.performRequestAsyncAndParseEntity(createIndexRequest, RequestConverters::createIndex, options, @@ -173,9 +182,12 @@ public void createAsync(CreateIndexRequest createIndexRequest, ActionListener * See * Put Mapping API on elastic.co + * @param putMappingRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public PutMappingResponse putMapping(PutMappingRequest putMappingRequest, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity(putMappingRequest, RequestConverters::putMapping, options, @@ -197,9 +209,11 @@ public PutMappingResponse putMapping(PutMappingRequest putMappingRequest, Header /** * Asynchronously updates the mappings on an index using the Put Mapping API - *

* See * Put Mapping API on elastic.co + * @param putMappingRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void putMappingAsync(PutMappingRequest putMappingRequest, RequestOptions options, ActionListener listener) { restHighLevelClient.performRequestAsyncAndParseEntity(putMappingRequest, RequestConverters::putMapping, options, @@ -222,33 +236,40 @@ public void putMappingAsync(PutMappingRequest putMappingRequest, ActionListener< /** * Retrieves the mappings on an index or indices using the Get Mapping API - *

* See * Get Mapping API on elastic.co + * @param getMappingsRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ - public GetMappingsResponse getMappings(GetMappingsRequest getMappingsRequest, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(getMappingsRequest, RequestConverters::getMappings, - GetMappingsResponse::fromXContent, emptySet(), headers); + public GetMappingsResponse getMappings(GetMappingsRequest getMappingsRequest, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(getMappingsRequest, RequestConverters::getMappings, options, + GetMappingsResponse::fromXContent, emptySet()); } /** * Asynchronously retrieves the mappings on an index on indices using the Get Mapping API - *

* See * Get Mapping API on elastic.co + * @param getMappingsRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ - public void getMappingsAsync(GetMappingsRequest getMappingsRequest, ActionListener listener, - Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(getMappingsRequest, RequestConverters::getMappings, - GetMappingsResponse::fromXContent, listener, emptySet(), headers); + public void getMappingsAsync(GetMappingsRequest getMappingsRequest, RequestOptions options, + ActionListener listener) { + restHighLevelClient.performRequestAsyncAndParseEntity(getMappingsRequest, RequestConverters::getMappings, options, + GetMappingsResponse::fromXContent, listener, emptySet()); } /** * Updates aliases using the Index Aliases API - *

- * See + * See * Index Aliases API on elastic.co + * @param indicesAliasesRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public IndicesAliasesResponse updateAliases(IndicesAliasesRequest indicesAliasesRequest, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity(indicesAliasesRequest, RequestConverters::updateAliases, options, @@ -271,10 +292,11 @@ public IndicesAliasesResponse updateAliases(IndicesAliasesRequest indicesAliases /** * Asynchronously updates aliases using the Index Aliases API - *

- * See + * See * Index Aliases API on elastic.co + * @param indicesAliasesRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void updateAliasesAsync(IndicesAliasesRequest indicesAliasesRequest, RequestOptions options, ActionListener listener) { @@ -299,9 +321,12 @@ public void updateAliasesAsync(IndicesAliasesRequest indicesAliasesRequest, Acti /** * Opens an index using the Open Index API - *

* See * Open Index API on elastic.co + * @param openIndexRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public OpenIndexResponse open(OpenIndexRequest openIndexRequest, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity(openIndexRequest, RequestConverters::openIndex, options, @@ -323,9 +348,11 @@ public OpenIndexResponse open(OpenIndexRequest openIndexRequest, Header... heade /** * Asynchronously opens an index using the Open Index API - *

* See * Open Index API on elastic.co + * @param openIndexRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void openAsync(OpenIndexRequest openIndexRequest, RequestOptions options, ActionListener listener) { restHighLevelClient.performRequestAsyncAndParseEntity(openIndexRequest, RequestConverters::openIndex, options, @@ -347,9 +374,12 @@ public void openAsync(OpenIndexRequest openIndexRequest, ActionListener * See * Close Index API on elastic.co + * @param closeIndexRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public CloseIndexResponse close(CloseIndexRequest closeIndexRequest, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity(closeIndexRequest, RequestConverters::closeIndex, options, @@ -371,9 +401,11 @@ public CloseIndexResponse close(CloseIndexRequest closeIndexRequest, Header... h /** * Asynchronously closes an index using the Close Index API - *

* See * Close Index API on elastic.co + * @param closeIndexRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void closeAsync(CloseIndexRequest closeIndexRequest, RequestOptions options, ActionListener listener) { restHighLevelClient.performRequestAsyncAndParseEntity(closeIndexRequest, RequestConverters::closeIndex, options, @@ -396,9 +428,12 @@ public void closeAsync(CloseIndexRequest closeIndexRequest, ActionListener * See * Indices Aliases API on elastic.co + * @param getAliasesRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request */ public boolean existsAlias(GetAliasesRequest getAliasesRequest, RequestOptions options) throws IOException { return restHighLevelClient.performRequest(getAliasesRequest, RequestConverters::existsAlias, options, @@ -420,9 +455,11 @@ public boolean existsAlias(GetAliasesRequest getAliasesRequest, Header... header /** * Asynchronously checks if one or more aliases exist using the Aliases Exist API - *

* See * Indices Aliases API on elastic.co + * @param getAliasesRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void existsAliasAsync(GetAliasesRequest getAliasesRequest, RequestOptions options, ActionListener listener) { restHighLevelClient.performRequestAsync(getAliasesRequest, RequestConverters::existsAlias, options, @@ -444,8 +481,11 @@ public void existsAliasAsync(GetAliasesRequest getAliasesRequest, ActionListener /** * Refresh one or more indices using the Refresh API - *

* See Refresh API on elastic.co + * @param refreshRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public RefreshResponse refresh(RefreshRequest refreshRequest, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity(refreshRequest, RequestConverters::refresh, options, @@ -466,8 +506,10 @@ public RefreshResponse refresh(RefreshRequest refreshRequest, Header... headers) /** * Asynchronously refresh one or more indices using the Refresh API - *

* See Refresh API on elastic.co + * @param refreshRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void refreshAsync(RefreshRequest refreshRequest, RequestOptions options, ActionListener listener) { restHighLevelClient.performRequestAsyncAndParseEntity(refreshRequest, RequestConverters::refresh, options, @@ -488,8 +530,11 @@ public void refreshAsync(RefreshRequest refreshRequest, ActionListener * See Flush API on elastic.co + * @param flushRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public FlushResponse flush(FlushRequest flushRequest, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity(flushRequest, RequestConverters::flush, options, @@ -510,8 +555,10 @@ public FlushResponse flush(FlushRequest flushRequest, Header... headers) throws /** * Asynchronously flush one or more indices using the Flush API - *

* See Flush API on elastic.co + * @param flushRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void flushAsync(FlushRequest flushRequest, RequestOptions options, ActionListener listener) { restHighLevelClient.performRequestAsyncAndParseEntity(flushRequest, RequestConverters::flush, options, @@ -530,11 +577,15 @@ public void flushAsync(FlushRequest flushRequest, ActionListener listener, emptySet(), headers); } - /** Initiate a synced flush manually using the synced flush API - *

- * See - * Synced flush API on elastic.co - */ + /** + * Initiate a synced flush manually using the synced flush API + * See + * Synced flush API on elastic.co + * @param syncedFlushRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response + */ public SyncedFlushResponse flushSynced(SyncedFlushRequest syncedFlushRequest, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity(syncedFlushRequest, RequestConverters::flushSynced, options, SyncedFlushResponse::fromXContent, emptySet()); @@ -542,9 +593,11 @@ public SyncedFlushResponse flushSynced(SyncedFlushRequest syncedFlushRequest, Re /** * Asynchronously initiate a synced flush manually using the synced flush API - *

* See * Synced flush API on elastic.co + * @param syncedFlushRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void flushSyncedAsync(SyncedFlushRequest syncedFlushRequest, RequestOptions options, ActionListener listener) { @@ -554,9 +607,12 @@ public void flushSyncedAsync(SyncedFlushRequest syncedFlushRequest, RequestOptio /** * Retrieve the settings of one or more indices - *

* See * Indices Get Settings API on elastic.co + * @param getSettingsRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public GetSettingsResponse getSettings(GetSettingsRequest getSettingsRequest, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity(getSettingsRequest, RequestConverters::getSettings, options, @@ -565,9 +621,11 @@ public GetSettingsResponse getSettings(GetSettingsRequest getSettingsRequest, Re /** * Asynchronously retrieve the settings of one or more indices - *

* See * Indices Get Settings API on elastic.co + * @param getSettingsRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void getSettingsAsync(GetSettingsRequest getSettingsRequest, RequestOptions options, ActionListener listener) { @@ -577,9 +635,12 @@ public void getSettingsAsync(GetSettingsRequest getSettingsRequest, RequestOptio /** * Force merge one or more indices using the Force Merge API - *

* See * Force Merge API on elastic.co + * @param forceMergeRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public ForceMergeResponse forceMerge(ForceMergeRequest forceMergeRequest, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity(forceMergeRequest, RequestConverters::forceMerge, options, @@ -601,9 +662,11 @@ public ForceMergeResponse forceMerge(ForceMergeRequest forceMergeRequest, Header /** * Asynchronously force merge one or more indices using the Force Merge API - *

* See * Force Merge API on elastic.co + * @param forceMergeRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void forceMergeAsync(ForceMergeRequest forceMergeRequest, RequestOptions options, ActionListener listener) { restHighLevelClient.performRequestAsyncAndParseEntity(forceMergeRequest, RequestConverters::forceMerge, options, @@ -625,9 +688,12 @@ public void forceMergeAsync(ForceMergeRequest forceMergeRequest, ActionListener< /** * Clears the cache of one or more indices using the Clear Cache API - *

* See * Clear Cache API on elastic.co + * @param clearIndicesCacheRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public ClearIndicesCacheResponse clearCache(ClearIndicesCacheRequest clearIndicesCacheRequest, RequestOptions options) throws IOException { @@ -650,9 +716,11 @@ public ClearIndicesCacheResponse clearCache(ClearIndicesCacheRequest clearIndice /** * Asynchronously clears the cache of one or more indices using the Clear Cache API - *

* See * Clear Cache API on elastic.co + * @param clearIndicesCacheRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void clearCacheAsync(ClearIndicesCacheRequest clearIndicesCacheRequest, RequestOptions options, ActionListener listener) { @@ -676,9 +744,12 @@ public void clearCacheAsync(ClearIndicesCacheRequest clearIndicesCacheRequest, A /** * Checks if the index (indices) exists or not. - *

* See * Indices Exists API on elastic.co + * @param request the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request */ public boolean exists(GetIndexRequest request, RequestOptions options) throws IOException { return restHighLevelClient.performRequest( @@ -710,9 +781,11 @@ public boolean exists(GetIndexRequest request, Header... headers) throws IOExcep /** * Asynchronously checks if the index (indices) exists or not. - *

* See * Indices Exists API on elastic.co + * @param request the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void existsAsync(GetIndexRequest request, RequestOptions options, ActionListener listener) { restHighLevelClient.performRequestAsync( @@ -746,9 +819,12 @@ public void existsAsync(GetIndexRequest request, ActionListener listene /** * Shrinks an index using the Shrink Index API - *

* See * Shrink Index API on elastic.co + * @param resizeRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public ResizeResponse shrink(ResizeRequest resizeRequest, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity(resizeRequest, RequestConverters::shrink, options, @@ -770,9 +846,11 @@ public ResizeResponse shrink(ResizeRequest resizeRequest, Header... headers) thr /** * Asynchronously shrinks an index using the Shrink index API - *

* See * Shrink Index API on elastic.co + * @param resizeRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void shrinkAsync(ResizeRequest resizeRequest, RequestOptions options, ActionListener listener) { restHighLevelClient.performRequestAsyncAndParseEntity(resizeRequest, RequestConverters::shrink, options, @@ -794,9 +872,12 @@ public void shrinkAsync(ResizeRequest resizeRequest, ActionListener * See * Split Index API on elastic.co + * @param resizeRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public ResizeResponse split(ResizeRequest resizeRequest, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity(resizeRequest, RequestConverters::split, options, @@ -818,9 +899,11 @@ public ResizeResponse split(ResizeRequest resizeRequest, Header... headers) thro /** * Asynchronously splits an index using the Split Index API - *

* See * Split Index API on elastic.co + * @param resizeRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void splitAsync(ResizeRequest resizeRequest, RequestOptions options, ActionListener listener) { restHighLevelClient.performRequestAsyncAndParseEntity(resizeRequest, RequestConverters::split, options, @@ -842,9 +925,12 @@ public void splitAsync(ResizeRequest resizeRequest, ActionListener * See * Rollover Index API on elastic.co + * @param rolloverRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public RolloverResponse rollover(RolloverRequest rolloverRequest, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity(rolloverRequest, RequestConverters::rollover, options, @@ -866,9 +952,11 @@ public RolloverResponse rollover(RolloverRequest rolloverRequest, Header... head /** * Asynchronously rolls over an index using the Rollover Index API - *

* See * Rollover Index API on elastic.co + * @param rolloverRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void rolloverAsync(RolloverRequest rolloverRequest, RequestOptions options, ActionListener listener) { restHighLevelClient.performRequestAsyncAndParseEntity(rolloverRequest, RequestConverters::rollover, options, @@ -890,9 +978,12 @@ public void rolloverAsync(RolloverRequest rolloverRequest, ActionListener * See Update Indices Settings * API on elastic.co + * @param updateSettingsRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public UpdateSettingsResponse putSettings(UpdateSettingsRequest updateSettingsRequest, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity(updateSettingsRequest, RequestConverters::indexPutSettings, options, @@ -914,9 +1005,11 @@ public UpdateSettingsResponse putSettings(UpdateSettingsRequest updateSettingsRe /** * Asynchronously updates specific index level settings using the Update Indices Settings API - *

* See Update Indices Settings * API on elastic.co + * @param updateSettingsRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void putSettingsAsync(UpdateSettingsRequest updateSettingsRequest, RequestOptions options, ActionListener listener) { @@ -940,9 +1033,12 @@ public void putSettingsAsync(UpdateSettingsRequest updateSettingsRequest, Action /** * Puts an index template using the Index Templates API - *

* See Index Templates API * on elastic.co + * @param putIndexTemplateRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public PutIndexTemplateResponse putTemplate(PutIndexTemplateRequest putIndexTemplateRequest, RequestOptions options) throws IOException { @@ -952,9 +1048,11 @@ public PutIndexTemplateResponse putTemplate(PutIndexTemplateRequest putIndexTemp /** * Asynchronously puts an index template using the Index Templates API - *

* See Index Templates API * on elastic.co + * @param putIndexTemplateRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void putTemplateAsync(PutIndexTemplateRequest putIndexTemplateRequest, RequestOptions options, ActionListener listener) { diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java index be6d0ff83fb6d..730b114c34331 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java @@ -45,9 +45,12 @@ public final class IngestClient { /** * Add a pipeline or update an existing pipeline - *

* See * Put Pipeline API on elastic.co + * @param request the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public WritePipelineResponse putPipeline(PutPipelineRequest request, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity( request, RequestConverters::putPipeline, options, @@ -56,9 +59,11 @@ public WritePipelineResponse putPipeline(PutPipelineRequest request, RequestOpti /** * Asynchronously add a pipeline or update an existing pipeline - *

* See * Put Pipeline API on elastic.co + * @param request the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void putPipelineAsync(PutPipelineRequest request, RequestOptions options, ActionListener listener) { restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::putPipeline, options, @@ -67,9 +72,12 @@ public void putPipelineAsync(PutPipelineRequest request, RequestOptions options, /** * Get an existing pipeline - *

* See * Get Pipeline API on elastic.co + * @param request the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public GetPipelineResponse getPipeline(GetPipelineRequest request, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity( request, RequestConverters::getPipeline, options, @@ -78,9 +86,11 @@ public GetPipelineResponse getPipeline(GetPipelineRequest request, RequestOption /** * Asynchronously get an existing pipeline - *

* See * Get Pipeline API on elastic.co + * @param request the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void getPipelineAsync(GetPipelineRequest request, RequestOptions options, ActionListener listener) { restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::getPipeline, options, @@ -89,10 +99,13 @@ public void getPipelineAsync(GetPipelineRequest request, RequestOptions options, /** * Delete an existing pipeline - *

* See * * Delete Pipeline API on elastic.co + * @param request the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public WritePipelineResponse deletePipeline(DeletePipelineRequest request, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity( request, RequestConverters::deletePipeline, options, @@ -101,10 +114,12 @@ public WritePipelineResponse deletePipeline(DeletePipelineRequest request, Reque /** * Asynchronously delete an existing pipeline - *

* See * * Delete Pipeline API on elastic.co + * @param request the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void deletePipelineAsync(DeletePipelineRequest request, RequestOptions options, ActionListener listener) { restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::deletePipeline, options, 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 e998b69c66c5c..a7ca9fe2bb7b2 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 @@ -286,8 +286,11 @@ public final TasksClient tasks() { /** * Executes a bulk request using the Bulk API - * * See Bulk API on elastic.co + * @param bulkRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public final BulkResponse bulk(BulkRequest bulkRequest, RequestOptions options) throws IOException { return performRequestAndParseEntity(bulkRequest, RequestConverters::bulk, options, BulkResponse::fromXContent, emptySet()); @@ -306,8 +309,10 @@ public final BulkResponse bulk(BulkRequest bulkRequest, Header... headers) throw /** * Asynchronously executes a bulk request using the Bulk API - * * See Bulk API on elastic.co + * @param bulkRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public final void bulkAsync(BulkRequest bulkRequest, RequestOptions options, ActionListener listener) { performRequestAsyncAndParseEntity(bulkRequest, RequestConverters::bulk, options, BulkResponse::fromXContent, listener, emptySet()); @@ -326,6 +331,9 @@ public final void bulkAsync(BulkRequest bulkRequest, ActionListenertrue if the ping succeeded, false otherwise + * @throws IOException in case there is a problem sending the request */ public final boolean ping(RequestOptions options) throws IOException { return performRequest(new MainRequest(), (request) -> RequestConverters.ping(), options, RestHighLevelClient::convertExistsResponse, @@ -343,7 +351,10 @@ public final boolean ping(Header... headers) throws IOException { } /** - * Get the cluster info otherwise provided when sending an HTTP request to port 9200 + * Get the cluster info otherwise provided when sending an HTTP request to '/' + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public final MainResponse info(RequestOptions options) throws IOException { return performRequestAndParseEntity(new MainRequest(), (request) -> RequestConverters.info(), options, @@ -362,8 +373,11 @@ public final MainResponse info(Header... headers) throws IOException { /** * Retrieves a document by id using the Get API - * * See Get API on elastic.co + * @param getRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public final GetResponse get(GetRequest getRequest, RequestOptions options) throws IOException { return performRequestAndParseEntity(getRequest, RequestConverters::get, options, GetResponse::fromXContent, singleton(404)); @@ -382,8 +396,10 @@ public final GetResponse get(GetRequest getRequest, Header... headers) throws IO /** * Asynchronously retrieves a document by id using the Get API - * * See Get API on elastic.co + * @param getRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public final void getAsync(GetRequest getRequest, RequestOptions options, ActionListener listener) { performRequestAsyncAndParseEntity(getRequest, RequestConverters::get, options, GetResponse::fromXContent, listener, @@ -404,8 +420,11 @@ public final void getAsync(GetRequest getRequest, ActionListener li /** * Retrieves multiple documents by id using the Multi Get API - * * See Multi Get API on elastic.co + * @param multiGetRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public final MultiGetResponse multiGet(MultiGetRequest multiGetRequest, RequestOptions options) throws IOException { return performRequestAndParseEntity(multiGetRequest, RequestConverters::multiGet, options, MultiGetResponse::fromXContent, @@ -426,8 +445,10 @@ public final MultiGetResponse multiGet(MultiGetRequest multiGetRequest, Header.. /** * Asynchronously retrieves multiple documents by id using the Multi Get API - * * See Multi Get API on elastic.co + * @param multiGetRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public final void multiGetAsync(MultiGetRequest multiGetRequest, RequestOptions options, ActionListener listener) { performRequestAsyncAndParseEntity(multiGetRequest, RequestConverters::multiGet, options, MultiGetResponse::fromXContent, listener, @@ -448,8 +469,11 @@ public final void multiGetAsync(MultiGetRequest multiGetRequest, ActionListener< /** * Checks for the existence of a document. Returns true if it exists, false otherwise - * * See Get API on elastic.co + * @param getRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return true if the document exists, false otherwise + * @throws IOException in case there is a problem sending the request */ public final boolean exists(GetRequest getRequest, RequestOptions options) throws IOException { return performRequest(getRequest, RequestConverters::exists, options, RestHighLevelClient::convertExistsResponse, emptySet()); @@ -468,8 +492,10 @@ public final boolean exists(GetRequest getRequest, Header... headers) throws IOE /** * Asynchronously checks for the existence of a document. Returns true if it exists, false otherwise - * * See Get API on elastic.co + * @param getRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public final void existsAsync(GetRequest getRequest, RequestOptions options, ActionListener listener) { performRequestAsync(getRequest, RequestConverters::exists, options, RestHighLevelClient::convertExistsResponse, listener, @@ -490,8 +516,11 @@ public final void existsAsync(GetRequest getRequest, ActionListener lis /** * Index a document using the Index API - * * See Index API on elastic.co + * @param indexRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public final IndexResponse index(IndexRequest indexRequest, RequestOptions options) throws IOException { return performRequestAndParseEntity(indexRequest, RequestConverters::index, options, IndexResponse::fromXContent, emptySet()); @@ -510,8 +539,10 @@ public final IndexResponse index(IndexRequest indexRequest, Header... headers) t /** * Asynchronously index a document using the Index API - * * See Index API on elastic.co + * @param indexRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public final void indexAsync(IndexRequest indexRequest, RequestOptions options, ActionListener listener) { performRequestAsyncAndParseEntity(indexRequest, RequestConverters::index, options, IndexResponse::fromXContent, listener, @@ -532,8 +563,11 @@ public final void indexAsync(IndexRequest indexRequest, ActionListener * See Update API on elastic.co + * @param updateRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public final UpdateResponse update(UpdateRequest updateRequest, RequestOptions options) throws IOException { return performRequestAndParseEntity(updateRequest, RequestConverters::update, options, UpdateResponse::fromXContent, emptySet()); @@ -552,8 +586,10 @@ public final UpdateResponse update(UpdateRequest updateRequest, Header... header /** * Asynchronously updates a document using the Update API - *

* See Update API on elastic.co + * @param updateRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public final void updateAsync(UpdateRequest updateRequest, RequestOptions options, ActionListener listener) { performRequestAsyncAndParseEntity(updateRequest, RequestConverters::update, options, UpdateResponse::fromXContent, listener, @@ -574,8 +610,11 @@ public final void updateAsync(UpdateRequest updateRequest, ActionListenerDelete API on elastic.co + * @param deleteRequest the reuqest + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public final DeleteResponse delete(DeleteRequest deleteRequest, RequestOptions options) throws IOException { return performRequestAndParseEntity(deleteRequest, RequestConverters::delete, options, DeleteResponse::fromXContent, @@ -596,8 +635,10 @@ public final DeleteResponse delete(DeleteRequest deleteRequest, Header... header /** * Asynchronously deletes a document by id using the Delete API - * * See Delete API on elastic.co + * @param deleteRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public final void deleteAsync(DeleteRequest deleteRequest, RequestOptions options, ActionListener listener) { performRequestAsyncAndParseEntity(deleteRequest, RequestConverters::delete, options, DeleteResponse::fromXContent, listener, @@ -617,9 +658,12 @@ public final void deleteAsync(DeleteRequest deleteRequest, ActionListenerSearch API on elastic.co + * @param searchRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public final SearchResponse search(SearchRequest searchRequest, RequestOptions options) throws IOException { return performRequestAndParseEntity(searchRequest, RequestConverters::search, options, SearchResponse::fromXContent, emptySet()); @@ -638,8 +682,10 @@ public final SearchResponse search(SearchRequest searchRequest, Header... header /** * Asynchronously executes a search using the Search API - * * See Search API on elastic.co + * @param searchRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public final void searchAsync(SearchRequest searchRequest, RequestOptions options, ActionListener listener) { performRequestAsyncAndParseEntity(searchRequest, RequestConverters::search, options, SearchResponse::fromXContent, listener, @@ -660,9 +706,12 @@ public final void searchAsync(SearchRequest searchRequest, ActionListenerMulti search API on * elastic.co + * @param multiSearchRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public final MultiSearchResponse multiSearch(MultiSearchRequest multiSearchRequest, RequestOptions options) throws IOException { return performRequestAndParseEntity(multiSearchRequest, RequestConverters::multiSearch, options, MultiSearchResponse::fromXContext, @@ -684,9 +733,11 @@ public final MultiSearchResponse multiSearch(MultiSearchRequest multiSearchReque /** * Asynchronously executes a multi search using the msearch API - * * See Multi search API on * elastic.co + * @param searchRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public final void multiSearchAsync(MultiSearchRequest searchRequest, RequestOptions options, ActionListener listener) { @@ -709,9 +760,12 @@ public final void multiSearchAsync(MultiSearchRequest searchRequest, ActionListe /** * Executes a search using the Search Scroll API - * * See Search Scroll * API on elastic.co + * @param searchScrollRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public final SearchResponse searchScroll(SearchScrollRequest searchScrollRequest, RequestOptions options) throws IOException { return performRequestAndParseEntity(searchScrollRequest, RequestConverters::searchScroll, options, SearchResponse::fromXContent, @@ -733,9 +787,11 @@ public final SearchResponse searchScroll(SearchScrollRequest searchScrollRequest /** * Asynchronously executes a search using the Search Scroll API - * * See Search Scroll * API on elastic.co + * @param searchScrollRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public final void searchScrollAsync(SearchScrollRequest searchScrollRequest, RequestOptions options, ActionListener listener) { @@ -759,9 +815,12 @@ public final void searchScrollAsync(SearchScrollRequest searchScrollRequest, /** * Clears one or more scroll ids using the Clear Scroll API - * * See * Clear Scroll API on elastic.co + * @param clearScrollRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public final ClearScrollResponse clearScroll(ClearScrollRequest clearScrollRequest, RequestOptions options) throws IOException { return performRequestAndParseEntity(clearScrollRequest, RequestConverters::clearScroll, options, ClearScrollResponse::fromXContent, @@ -783,9 +842,11 @@ public final ClearScrollResponse clearScroll(ClearScrollRequest clearScrollReque /** * Asynchronously clears one or more scroll ids using the Clear Scroll API - * * See * Clear Scroll API on elastic.co + * @param clearScrollRequest the reuqest + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public final void clearScrollAsync(ClearScrollRequest clearScrollRequest, RequestOptions options, ActionListener listener) { @@ -809,9 +870,12 @@ public final void clearScrollAsync(ClearScrollRequest clearScrollRequest, /** * Executes a request using the Search Template API. - * * See Search Template API * on elastic.co. + * @param searchTemplateRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public final SearchTemplateResponse searchTemplate(SearchTemplateRequest searchTemplateRequest, RequestOptions options) throws IOException { @@ -831,12 +895,14 @@ public final void searchTemplateAsync(SearchTemplateRequest searchTemplateReques SearchTemplateResponse::fromXContent, listener, emptySet()); } - /** * Executes a request using the Ranking Evaluation API. - * * See Ranking Evaluation API * on elastic.co + * @param rankEvalRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public final RankEvalResponse rankEval(RankEvalRequest rankEvalRequest, RequestOptions options) throws IOException { return performRequestAndParseEntity(rankEvalRequest, RequestConverters::rankEval, options, RankEvalResponse::fromXContent, @@ -858,9 +924,11 @@ public final RankEvalResponse rankEval(RankEvalRequest rankEvalRequest, Header.. /** * Asynchronously executes a request using the Ranking Evaluation API. - * * See Ranking Evaluation API * on elastic.co + * @param rankEvalRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public final void rankEvalAsync(RankEvalRequest rankEvalRequest, RequestOptions options, ActionListener listener) { performRequestAsyncAndParseEntity(rankEvalRequest, RequestConverters::rankEval, options, RankEvalResponse::fromXContent, listener, @@ -882,9 +950,12 @@ public final void rankEvalAsync(RankEvalRequest rankEvalRequest, ActionListener< /** * Executes a request using the Field Capabilities API. - * * See Field Capabilities API * on elastic.co. + * @param fieldCapabilitiesRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public final FieldCapabilitiesResponse fieldCaps(FieldCapabilitiesRequest fieldCapabilitiesRequest, RequestOptions options) throws IOException { @@ -894,9 +965,11 @@ public final FieldCapabilitiesResponse fieldCaps(FieldCapabilitiesRequest fieldC /** * Asynchronously executes a request using the Field Capabilities API. - * * See Field Capabilities API * on elastic.co. + * @param fieldCapabilitiesRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public final void fieldCapsAsync(FieldCapabilitiesRequest fieldCapabilitiesRequest, RequestOptions options, ActionListener listener) { diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/SnapshotClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/SnapshotClient.java index ad249ea65e45a..56ce007073cae 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/SnapshotClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/SnapshotClient.java @@ -48,9 +48,12 @@ public final class SnapshotClient { /** * Gets a list of snapshot repositories. If the list of repositories is empty or it contains a single element "_all", all * registered repositories are returned. - *

* See Snapshot and Restore * API on elastic.co + * @param getRepositoriesRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public GetRepositoriesResponse getRepositories(GetRepositoriesRequest getRepositoriesRequest, RequestOptions options) throws IOException { @@ -61,9 +64,11 @@ public GetRepositoriesResponse getRepositories(GetRepositoriesRequest getReposit /** * Asynchronously gets a list of snapshot repositories. If the list of repositories is empty or it contains a single element "_all", all * registered repositories are returned. - *

* See Snapshot and Restore * API on elastic.co + * @param getRepositoriesRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void getRepositoriesAsync(GetRepositoriesRequest getRepositoriesRequest, RequestOptions options, ActionListener listener) { @@ -73,9 +78,12 @@ public void getRepositoriesAsync(GetRepositoriesRequest getRepositoriesRequest, /** * Creates a snapshot repository. - *

* See Snapshot and Restore * API on elastic.co + * @param putRepositoryRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public PutRepositoryResponse createRepository(PutRepositoryRequest putRepositoryRequest, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity(putRepositoryRequest, RequestConverters::createRepository, options, @@ -84,9 +92,11 @@ public PutRepositoryResponse createRepository(PutRepositoryRequest putRepository /** * Asynchronously creates a snapshot repository. - *

* See Snapshot and Restore * API on elastic.co + * @param putRepositoryRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void createRepositoryAsync(PutRepositoryRequest putRepositoryRequest, RequestOptions options, ActionListener listener) { @@ -96,9 +106,12 @@ public void createRepositoryAsync(PutRepositoryRequest putRepositoryRequest, Req /** * Deletes a snapshot repository. - *

* See Snapshot and Restore * API on elastic.co + * @param deleteRepositoryRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public DeleteRepositoryResponse deleteRepository(DeleteRepositoryRequest deleteRepositoryRequest, RequestOptions options) throws IOException { @@ -108,9 +121,11 @@ public DeleteRepositoryResponse deleteRepository(DeleteRepositoryRequest deleteR /** * Asynchronously deletes a snapshot repository. - *

* See Snapshot and Restore * API on elastic.co + * @param deleteRepositoryRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void deleteRepositoryAsync(DeleteRepositoryRequest deleteRepositoryRequest, RequestOptions options, ActionListener listener) { @@ -120,9 +135,12 @@ public void deleteRepositoryAsync(DeleteRepositoryRequest deleteRepositoryReques /** * Verifies a snapshot repository. - *

* See Snapshot and Restore * API on elastic.co + * @param verifyRepositoryRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public VerifyRepositoryResponse verifyRepository(VerifyRepositoryRequest verifyRepositoryRequest, RequestOptions options) throws IOException { @@ -132,9 +150,11 @@ public VerifyRepositoryResponse verifyRepository(VerifyRepositoryRequest verifyR /** * Asynchronously verifies a snapshot repository. - *

* See Snapshot and Restore * API on elastic.co + * @param verifyRepositoryRequest the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void verifyRepositoryAsync(VerifyRepositoryRequest verifyRepositoryRequest, RequestOptions options, ActionListener listener) { 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 cf4846537cf9f..792b5bcbb2ad9 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 @@ -41,9 +41,12 @@ public final class TasksClient { /** * Get current tasks using the Task Management API - *

* See * Task Management API on elastic.co + * @param request the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response */ public ListTasksResponse list(ListTasksRequest request, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity(request, RequestConverters::listTasks, options, @@ -52,9 +55,11 @@ public ListTasksResponse list(ListTasksRequest request, RequestOptions options) /** * Asynchronously get current tasks using the Task Management API - *

* See * Task Management API on elastic.co + * @param request the request + * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion */ public void listAsync(ListTasksRequest request, RequestOptions options, ActionListener listener) { restHighLevelClient.performRequestAsyncAndParseEntity(request, RequestConverters::listTasks, options, From cb6331ba7f032ea491c540e3f25b114b68d06672 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 6 Jun 2018 13:28:00 +0200 Subject: [PATCH 5/7] add punctuation marks --- .../elasticsearch/client/ClusterClient.java | 8 +- .../elasticsearch/client/IndicesClient.java | 136 +++++++++--------- .../elasticsearch/client/IngestClient.java | 12 +- .../client/RestHighLevelClient.java | 90 ++++++------ .../org/elasticsearch/client/TasksClient.java | 4 +- 5 files changed, 125 insertions(+), 125 deletions(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java index 202e0d4035afc..288e0ab188e66 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java @@ -41,7 +41,7 @@ public final class ClusterClient { } /** - * Updates cluster wide specific settings using the Cluster Update Settings API + * Updates cluster wide specific settings using the Cluster Update Settings API. * See Cluster Update Settings * API on elastic.co * @param clusterUpdateSettingsRequest the request @@ -56,7 +56,7 @@ public ClusterUpdateSettingsResponse putSettings(ClusterUpdateSettingsRequest cl } /** - * Updates cluster wide specific settings using the Cluster Update Settings API + * Updates cluster wide specific settings using the Cluster Update Settings API. *

* See Cluster Update Settings * API on elastic.co @@ -70,7 +70,7 @@ public ClusterUpdateSettingsResponse putSettings(ClusterUpdateSettingsRequest cl } /** - * Asynchronously updates cluster wide specific settings using the Cluster Update Settings API + * Asynchronously updates cluster wide specific settings using the Cluster Update Settings API. * See Cluster Update Settings * API on elastic.co * @param clusterUpdateSettingsRequest the request @@ -83,7 +83,7 @@ public void putSettingsAsync(ClusterUpdateSettingsRequest clusterUpdateSettingsR options, ClusterUpdateSettingsResponse::fromXContent, listener, emptySet()); } /** - * Asynchronously updates cluster wide specific settings using the Cluster Update Settings API + * Asynchronously updates cluster wide specific settings using the Cluster Update Settings API. *

* See Cluster Update Settings * API on elastic.co diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java index 43484702c946e..52fefcf6e8eb0 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java @@ -75,7 +75,7 @@ public final class IndicesClient { } /** - * Deletes an index using the Delete Index API + * Deletes an index using the Delete Index API. * See * Delete Index API on elastic.co * @param deleteIndexRequest the request @@ -89,7 +89,7 @@ public DeleteIndexResponse delete(DeleteIndexRequest deleteIndexRequest, Request } /** - * Deletes an index using the Delete Index API + * Deletes an index using the Delete Index API. *

* See * Delete Index API on elastic.co @@ -102,7 +102,7 @@ public DeleteIndexResponse delete(DeleteIndexRequest deleteIndexRequest, Header. } /** - * Asynchronously deletes an index using the Delete Index API + * Asynchronously deletes an index using the Delete Index API. * See * Delete Index API on elastic.co * @param deleteIndexRequest the request @@ -115,7 +115,7 @@ public void deleteAsync(DeleteIndexRequest deleteIndexRequest, RequestOptions op } /** - * Asynchronously deletes an index using the Delete Index API + * Asynchronously deletes an index using the Delete Index API. *

* See * Delete Index API on elastic.co @@ -128,7 +128,7 @@ public void deleteAsync(DeleteIndexRequest deleteIndexRequest, ActionListener * Create Index API on elastic.co * @param createIndexRequest the request @@ -142,7 +142,7 @@ public CreateIndexResponse create(CreateIndexRequest createIndexRequest, Request } /** - * Creates an index using the Create Index API + * Creates an index using the Create Index API. *

* See * Create Index API on elastic.co @@ -155,7 +155,7 @@ public CreateIndexResponse create(CreateIndexRequest createIndexRequest, Header. } /** - * Asynchronously creates an index using the Create Index API + * Asynchronously creates an index using the Create Index API. * See * Create Index API on elastic.co * @param createIndexRequest the request @@ -168,7 +168,7 @@ public void createAsync(CreateIndexRequest createIndexRequest, RequestOptions op } /** - * Asynchronously creates an index using the Create Index API + * Asynchronously creates an index using the Create Index API. *

* See * Create Index API on elastic.co @@ -181,7 +181,7 @@ public void createAsync(CreateIndexRequest createIndexRequest, ActionListener * Put Mapping API on elastic.co * @param putMappingRequest the request @@ -195,7 +195,7 @@ public PutMappingResponse putMapping(PutMappingRequest putMappingRequest, Reques } /** - * Updates the mappings on an index using the Put Mapping API + * Updates the mappings on an index using the Put Mapping API. *

* See * Put Mapping API on elastic.co @@ -208,7 +208,7 @@ public PutMappingResponse putMapping(PutMappingRequest putMappingRequest, Header } /** - * Asynchronously updates the mappings on an index using the Put Mapping API + * Asynchronously updates the mappings on an index using the Put Mapping API. * See * Put Mapping API on elastic.co * @param putMappingRequest the request @@ -221,7 +221,7 @@ public void putMappingAsync(PutMappingRequest putMappingRequest, RequestOptions } /** - * Asynchronously updates the mappings on an index using the Put Mapping API + * Asynchronously updates the mappings on an index using the Put Mapping API. *

* See * Put Mapping API on elastic.co @@ -235,7 +235,7 @@ public void putMappingAsync(PutMappingRequest putMappingRequest, ActionListener< } /** - * Retrieves the mappings on an index or indices using the Get Mapping API + * Retrieves the mappings on an index or indices using the Get Mapping API. * See * Get Mapping API on elastic.co * @param getMappingsRequest the request @@ -249,7 +249,7 @@ public GetMappingsResponse getMappings(GetMappingsRequest getMappingsRequest, Re } /** - * Asynchronously retrieves the mappings on an index on indices using the Get Mapping API + * Asynchronously retrieves the mappings on an index on indices using the Get Mapping API. * See * Get Mapping API on elastic.co * @param getMappingsRequest the request @@ -263,7 +263,7 @@ public void getMappingsAsync(GetMappingsRequest getMappingsRequest, RequestOptio } /** - * Updates aliases using the Index Aliases API + * Updates aliases using the Index Aliases API. * See * Index Aliases API on elastic.co * @param indicesAliasesRequest the request @@ -277,7 +277,7 @@ public IndicesAliasesResponse updateAliases(IndicesAliasesRequest indicesAliases } /** - * Updates aliases using the Index Aliases API + * Updates aliases using the Index Aliases API. *

* See @@ -291,7 +291,7 @@ public IndicesAliasesResponse updateAliases(IndicesAliasesRequest indicesAliases } /** - * Asynchronously updates aliases using the Index Aliases API + * Asynchronously updates aliases using the Index Aliases API. * See * Index Aliases API on elastic.co * @param indicesAliasesRequest the request @@ -305,7 +305,7 @@ public void updateAliasesAsync(IndicesAliasesRequest indicesAliasesRequest, Requ } /** - * Asynchronously updates aliases using the Index Aliases API + * Asynchronously updates aliases using the Index Aliases API. *

* See @@ -320,7 +320,7 @@ public void updateAliasesAsync(IndicesAliasesRequest indicesAliasesRequest, Acti } /** - * Opens an index using the Open Index API + * Opens an index using the Open Index API. * See * Open Index API on elastic.co * @param openIndexRequest the request @@ -334,7 +334,7 @@ public OpenIndexResponse open(OpenIndexRequest openIndexRequest, RequestOptions } /** - * Opens an index using the Open Index API + * Opens an index using the Open Index API. *

* See * Open Index API on elastic.co @@ -347,7 +347,7 @@ public OpenIndexResponse open(OpenIndexRequest openIndexRequest, Header... heade } /** - * Asynchronously opens an index using the Open Index API + * Asynchronously opens an index using the Open Index API. * See * Open Index API on elastic.co * @param openIndexRequest the request @@ -360,7 +360,7 @@ public void openAsync(OpenIndexRequest openIndexRequest, RequestOptions options, } /** - * Asynchronously opens an index using the Open Index API + * Asynchronously opens an index using the Open Index API. *

* See * Open Index API on elastic.co @@ -373,7 +373,7 @@ public void openAsync(OpenIndexRequest openIndexRequest, ActionListener * Close Index API on elastic.co * @param closeIndexRequest the request @@ -387,7 +387,7 @@ public CloseIndexResponse close(CloseIndexRequest closeIndexRequest, RequestOpti } /** - * Closes an index using the Close Index API + * Closes an index using the Close Index API. *

* See * Close Index API on elastic.co @@ -400,7 +400,7 @@ public CloseIndexResponse close(CloseIndexRequest closeIndexRequest, Header... h } /** - * Asynchronously closes an index using the Close Index API + * Asynchronously closes an index using the Close Index API. * See * Close Index API on elastic.co * @param closeIndexRequest the request @@ -414,7 +414,7 @@ public void closeAsync(CloseIndexRequest closeIndexRequest, RequestOptions optio /** - * Asynchronously closes an index using the Close Index API + * Asynchronously closes an index using the Close Index API. *

* See * Close Index API on elastic.co @@ -427,7 +427,7 @@ public void closeAsync(CloseIndexRequest closeIndexRequest, ActionListener * Indices Aliases API on elastic.co * @param getAliasesRequest the request @@ -441,7 +441,7 @@ public boolean existsAlias(GetAliasesRequest getAliasesRequest, RequestOptions o } /** - * Checks if one or more aliases exist using the Aliases Exist API + * Checks if one or more aliases exist using the Aliases Exist API. *

* See * Indices Aliases API on elastic.co @@ -454,7 +454,7 @@ public boolean existsAlias(GetAliasesRequest getAliasesRequest, Header... header } /** - * Asynchronously checks if one or more aliases exist using the Aliases Exist API + * Asynchronously checks if one or more aliases exist using the Aliases Exist API. * See * Indices Aliases API on elastic.co * @param getAliasesRequest the request @@ -467,7 +467,7 @@ public void existsAliasAsync(GetAliasesRequest getAliasesRequest, RequestOptions } /** - * Asynchronously checks if one or more aliases exist using the Aliases Exist API + * Asynchronously checks if one or more aliases exist using the Aliases Exist API. *

* See * Indices Aliases API on elastic.co @@ -480,7 +480,7 @@ public void existsAliasAsync(GetAliasesRequest getAliasesRequest, ActionListener } /** - * Refresh one or more indices using the Refresh API + * Refresh one or more indices using the Refresh API. * See Refresh API on elastic.co * @param refreshRequest the request * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -493,7 +493,7 @@ public RefreshResponse refresh(RefreshRequest refreshRequest, RequestOptions opt } /** - * Refresh one or more indices using the Refresh API + * Refresh one or more indices using the Refresh API. *

* See Refresh API on elastic.co * @deprecated Prefer {@link #refresh(RefreshRequest, RequestOptions)} @@ -505,7 +505,7 @@ public RefreshResponse refresh(RefreshRequest refreshRequest, Header... headers) } /** - * Asynchronously refresh one or more indices using the Refresh API + * Asynchronously refresh one or more indices using the Refresh API. * See Refresh API on elastic.co * @param refreshRequest the request * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -517,7 +517,7 @@ public void refreshAsync(RefreshRequest refreshRequest, RequestOptions options, } /** - * Asynchronously refresh one or more indices using the Refresh API + * Asynchronously refresh one or more indices using the Refresh API. *

* See Refresh API on elastic.co * @deprecated Prefer {@link #refreshAsync(RefreshRequest, RequestOptions, ActionListener)} @@ -529,7 +529,7 @@ public void refreshAsync(RefreshRequest refreshRequest, ActionListener Flush API on elastic.co * @param flushRequest the request * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -542,7 +542,7 @@ public FlushResponse flush(FlushRequest flushRequest, RequestOptions options) th } /** - * Flush one or more indices using the Flush API + * Flush one or more indices using the Flush API. *

* See Flush API on elastic.co * @deprecated Prefer {@link #flush(FlushRequest, RequestOptions)} @@ -554,7 +554,7 @@ public FlushResponse flush(FlushRequest flushRequest, Header... headers) throws } /** - * Asynchronously flush one or more indices using the Flush API + * Asynchronously flush one or more indices using the Flush API. * See Flush API on elastic.co * @param flushRequest the request * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -566,7 +566,7 @@ public void flushAsync(FlushRequest flushRequest, RequestOptions options, Action } /** - * Asynchronously flush one or more indices using the Flush API + * Asynchronously flush one or more indices using the Flush API. *

* See Flush API on elastic.co * @deprecated Prefer {@link #flushAsync(FlushRequest, RequestOptions, ActionListener)} @@ -578,7 +578,7 @@ public void flushAsync(FlushRequest flushRequest, ActionListener } /** - * Initiate a synced flush manually using the synced flush API + * Initiate a synced flush manually using the synced flush API. * See * Synced flush API on elastic.co * @param syncedFlushRequest the request @@ -592,7 +592,7 @@ public SyncedFlushResponse flushSynced(SyncedFlushRequest syncedFlushRequest, Re } /** - * Asynchronously initiate a synced flush manually using the synced flush API + * Asynchronously initiate a synced flush manually using the synced flush API. * See * Synced flush API on elastic.co * @param syncedFlushRequest the request @@ -606,7 +606,7 @@ public void flushSyncedAsync(SyncedFlushRequest syncedFlushRequest, RequestOptio } /** - * Retrieve the settings of one or more indices + * Retrieve the settings of one or more indices. * See * Indices Get Settings API on elastic.co * @param getSettingsRequest the request @@ -620,7 +620,7 @@ public GetSettingsResponse getSettings(GetSettingsRequest getSettingsRequest, Re } /** - * Asynchronously retrieve the settings of one or more indices + * Asynchronously retrieve the settings of one or more indices. * See * Indices Get Settings API on elastic.co * @param getSettingsRequest the request @@ -634,7 +634,7 @@ public void getSettingsAsync(GetSettingsRequest getSettingsRequest, RequestOptio } /** - * Force merge one or more indices using the Force Merge API + * Force merge one or more indices using the Force Merge API. * See * Force Merge API on elastic.co * @param forceMergeRequest the request @@ -648,7 +648,7 @@ public ForceMergeResponse forceMerge(ForceMergeRequest forceMergeRequest, Reques } /** - * Force merge one or more indices using the Force Merge API + * Force merge one or more indices using the Force Merge API. *

* See * Force Merge API on elastic.co @@ -661,7 +661,7 @@ public ForceMergeResponse forceMerge(ForceMergeRequest forceMergeRequest, Header } /** - * Asynchronously force merge one or more indices using the Force Merge API + * Asynchronously force merge one or more indices using the Force Merge API. * See * Force Merge API on elastic.co * @param forceMergeRequest the request @@ -674,7 +674,7 @@ public void forceMergeAsync(ForceMergeRequest forceMergeRequest, RequestOptions } /** - * Asynchronously force merge one or more indices using the Force Merge API + * Asynchronously force merge one or more indices using the Force Merge API. *

* See * Force Merge API on elastic.co @@ -687,7 +687,7 @@ public void forceMergeAsync(ForceMergeRequest forceMergeRequest, ActionListener< } /** - * Clears the cache of one or more indices using the Clear Cache API + * Clears the cache of one or more indices using the Clear Cache API. * See * Clear Cache API on elastic.co * @param clearIndicesCacheRequest the request @@ -702,7 +702,7 @@ public ClearIndicesCacheResponse clearCache(ClearIndicesCacheRequest clearIndice } /** - * Clears the cache of one or more indices using the Clear Cache API + * Clears the cache of one or more indices using the Clear Cache API. *

* See * Clear Cache API on elastic.co @@ -715,7 +715,7 @@ public ClearIndicesCacheResponse clearCache(ClearIndicesCacheRequest clearIndice } /** - * Asynchronously clears the cache of one or more indices using the Clear Cache API + * Asynchronously clears the cache of one or more indices using the Clear Cache API. * See * Clear Cache API on elastic.co * @param clearIndicesCacheRequest the request @@ -729,7 +729,7 @@ public void clearCacheAsync(ClearIndicesCacheRequest clearIndicesCacheRequest, R } /** - * Asynchronously clears the cache of one or more indices using the Clear Cache API + * Asynchronously clears the cache of one or more indices using the Clear Cache API. *

* See * Clear Cache API on elastic.co @@ -818,7 +818,7 @@ public void existsAsync(GetIndexRequest request, ActionListener listene } /** - * Shrinks an index using the Shrink Index API + * Shrinks an index using the Shrink Index API. * See * Shrink Index API on elastic.co * @param resizeRequest the request @@ -832,7 +832,7 @@ public ResizeResponse shrink(ResizeRequest resizeRequest, RequestOptions options } /** - * Shrinks an index using the Shrink Index API + * Shrinks an index using the Shrink Index API. *

* See * Shrink Index API on elastic.co @@ -845,7 +845,7 @@ public ResizeResponse shrink(ResizeRequest resizeRequest, Header... headers) thr } /** - * Asynchronously shrinks an index using the Shrink index API + * Asynchronously shrinks an index using the Shrink index API. * See * Shrink Index API on elastic.co * @param resizeRequest the request @@ -858,7 +858,7 @@ public void shrinkAsync(ResizeRequest resizeRequest, RequestOptions options, Act } /** - * Asynchronously shrinks an index using the Shrink index API + * Asynchronously shrinks an index using the Shrink index API. *

* See * Shrink Index API on elastic.co @@ -871,7 +871,7 @@ public void shrinkAsync(ResizeRequest resizeRequest, ActionListener * Split Index API on elastic.co * @param resizeRequest the request @@ -885,7 +885,7 @@ public ResizeResponse split(ResizeRequest resizeRequest, RequestOptions options) } /** - * Splits an index using the Split Index API + * Splits an index using the Split Index API. *

* See * Split Index API on elastic.co @@ -898,7 +898,7 @@ public ResizeResponse split(ResizeRequest resizeRequest, Header... headers) thro } /** - * Asynchronously splits an index using the Split Index API + * Asynchronously splits an index using the Split Index API. * See * Split Index API on elastic.co * @param resizeRequest the request @@ -911,7 +911,7 @@ public void splitAsync(ResizeRequest resizeRequest, RequestOptions options, Acti } /** - * Asynchronously splits an index using the Split Index API + * Asynchronously splits an index using the Split Index API. *

* See * Split Index API on elastic.co @@ -924,7 +924,7 @@ public void splitAsync(ResizeRequest resizeRequest, ActionListener * Rollover Index API on elastic.co * @param rolloverRequest the request @@ -938,7 +938,7 @@ public RolloverResponse rollover(RolloverRequest rolloverRequest, RequestOptions } /** - * Rolls over an index using the Rollover Index API + * Rolls over an index using the Rollover Index API. *

* See * Rollover Index API on elastic.co @@ -951,7 +951,7 @@ public RolloverResponse rollover(RolloverRequest rolloverRequest, Header... head } /** - * Asynchronously rolls over an index using the Rollover Index API + * Asynchronously rolls over an index using the Rollover Index API. * See * Rollover Index API on elastic.co * @param rolloverRequest the request @@ -964,7 +964,7 @@ public void rolloverAsync(RolloverRequest rolloverRequest, RequestOptions option } /** - * Asynchronously rolls over an index using the Rollover Index API + * Asynchronously rolls over an index using the Rollover Index API. *

* See * Rollover Index API on elastic.co @@ -977,7 +977,7 @@ public void rolloverAsync(RolloverRequest rolloverRequest, ActionListener Update Indices Settings * API on elastic.co * @param updateSettingsRequest the request @@ -991,7 +991,7 @@ public UpdateSettingsResponse putSettings(UpdateSettingsRequest updateSettingsRe } /** - * Updates specific index level settings using the Update Indices Settings API + * Updates specific index level settings using the Update Indices Settings API. *

* See Update Indices Settings * API on elastic.co @@ -1004,7 +1004,7 @@ public UpdateSettingsResponse putSettings(UpdateSettingsRequest updateSettingsRe } /** - * Asynchronously updates specific index level settings using the Update Indices Settings API + * Asynchronously updates specific index level settings using the Update Indices Settings API. * See Update Indices Settings * API on elastic.co * @param updateSettingsRequest the request @@ -1018,7 +1018,7 @@ public void putSettingsAsync(UpdateSettingsRequest updateSettingsRequest, Reques } /** - * Asynchronously updates specific index level settings using the Update Indices Settings API + * Asynchronously updates specific index level settings using the Update Indices Settings API. *

* See Update Indices Settings * API on elastic.co @@ -1032,7 +1032,7 @@ public void putSettingsAsync(UpdateSettingsRequest updateSettingsRequest, Action } /** - * Puts an index template using the Index Templates API + * Puts an index template using the Index Templates API. * See Index Templates API * on elastic.co * @param putIndexTemplateRequest the request @@ -1047,7 +1047,7 @@ public PutIndexTemplateResponse putTemplate(PutIndexTemplateRequest putIndexTemp } /** - * Asynchronously puts an index template using the Index Templates API + * Asynchronously puts an index template using the Index Templates API. * See Index Templates API * on elastic.co * @param putIndexTemplateRequest the request diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java index 730b114c34331..bb7c4a9457b3c 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java @@ -44,7 +44,7 @@ public final class IngestClient { } /** - * Add a pipeline or update an existing pipeline + * Add a pipeline or update an existing pipeline. * See * Put Pipeline API on elastic.co * @param request the request @@ -58,7 +58,7 @@ public WritePipelineResponse putPipeline(PutPipelineRequest request, RequestOpti } /** - * Asynchronously add a pipeline or update an existing pipeline + * Asynchronously add a pipeline or update an existing pipeline. * See * Put Pipeline API on elastic.co * @param request the request @@ -71,7 +71,7 @@ public void putPipelineAsync(PutPipelineRequest request, RequestOptions options, } /** - * Get an existing pipeline + * Get an existing pipeline. * See * Get Pipeline API on elastic.co * @param request the request @@ -85,7 +85,7 @@ public GetPipelineResponse getPipeline(GetPipelineRequest request, RequestOption } /** - * Asynchronously get an existing pipeline + * Asynchronously get an existing pipeline. * See * Get Pipeline API on elastic.co * @param request the request @@ -98,7 +98,7 @@ public void getPipelineAsync(GetPipelineRequest request, RequestOptions options, } /** - * Delete an existing pipeline + * Delete an existing pipeline. * See * * Delete Pipeline API on elastic.co @@ -113,7 +113,7 @@ public WritePipelineResponse deletePipeline(DeletePipelineRequest request, Reque } /** - * Asynchronously delete an existing pipeline + * Asynchronously delete an existing pipeline. * See * * Delete Pipeline API on elastic.co 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 a7ca9fe2bb7b2..48955bf2a702a 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 @@ -285,7 +285,7 @@ public final TasksClient tasks() { } /** - * Executes a bulk request using the Bulk API + * Executes a bulk request using the Bulk API. * See Bulk API on elastic.co * @param bulkRequest the request * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -297,7 +297,7 @@ public final BulkResponse bulk(BulkRequest bulkRequest, RequestOptions options) } /** - * Executes a bulk request using the Bulk API + * Executes a bulk request using the Bulk API. * * See Bulk API on elastic.co * @deprecated Prefer {@link #bulk(BulkRequest, RequestOptions)} @@ -308,7 +308,7 @@ public final BulkResponse bulk(BulkRequest bulkRequest, Header... headers) throw } /** - * Asynchronously executes a bulk request using the Bulk API + * Asynchronously executes a bulk request using the Bulk API. * See Bulk API on elastic.co * @param bulkRequest the request * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -319,7 +319,7 @@ public final void bulkAsync(BulkRequest bulkRequest, RequestOptions options, Act } /** - * Asynchronously executes a bulk request using the Bulk API + * Asynchronously executes a bulk request using the Bulk API. * * See Bulk API on elastic.co * @deprecated Prefer {@link #bulkAsync(BulkRequest, RequestOptions, ActionListener)} @@ -372,7 +372,7 @@ public final MainResponse info(Header... headers) throws IOException { } /** - * Retrieves a document by id using the Get API + * Retrieves a document by id using the Get API. * See Get API on elastic.co * @param getRequest the request * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -384,7 +384,7 @@ public final GetResponse get(GetRequest getRequest, RequestOptions options) thro } /** - * Retrieves a document by id using the Get API + * Retrieves a document by id using the Get API. * * See Get API on elastic.co * @deprecated Prefer {@link #get(GetRequest, RequestOptions)} @@ -395,7 +395,7 @@ public final GetResponse get(GetRequest getRequest, Header... headers) throws IO } /** - * Asynchronously retrieves a document by id using the Get API + * Asynchronously retrieves a document by id using the Get API. * See Get API on elastic.co * @param getRequest the request * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -407,7 +407,7 @@ public final void getAsync(GetRequest getRequest, RequestOptions options, Action } /** - * Asynchronously retrieves a document by id using the Get API + * Asynchronously retrieves a document by id using the Get API. * * See Get API on elastic.co * @deprecated Prefer {@link #getAsync(GetRequest, RequestOptions, ActionListener)} @@ -419,7 +419,7 @@ public final void getAsync(GetRequest getRequest, ActionListener li } /** - * Retrieves multiple documents by id using the Multi Get API + * Retrieves multiple documents by id using the Multi Get API. * See Multi Get API on elastic.co * @param multiGetRequest the request * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -432,7 +432,7 @@ public final MultiGetResponse multiGet(MultiGetRequest multiGetRequest, RequestO } /** - * Retrieves multiple documents by id using the Multi Get API + * Retrieves multiple documents by id using the Multi Get API. * * See Multi Get API on elastic.co * @deprecated Prefer {@link #multiGet(MultiGetRequest, RequestOptions)} @@ -444,7 +444,7 @@ public final MultiGetResponse multiGet(MultiGetRequest multiGetRequest, Header.. } /** - * Asynchronously retrieves multiple documents by id using the Multi Get API + * Asynchronously retrieves multiple documents by id using the Multi Get API. * See Multi Get API on elastic.co * @param multiGetRequest the request * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -456,7 +456,7 @@ public final void multiGetAsync(MultiGetRequest multiGetRequest, RequestOptions } /** - * Asynchronously retrieves multiple documents by id using the Multi Get API + * 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)} @@ -468,7 +468,7 @@ public final void multiGetAsync(MultiGetRequest multiGetRequest, ActionListener< } /** - * Checks for the existence of a document. Returns true if it exists, false otherwise + * Checks for the existence of a document. Returns true if it exists, false otherwise. * See Get API on elastic.co * @param getRequest the request * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -480,7 +480,7 @@ public final boolean exists(GetRequest getRequest, RequestOptions options) throw } /** - * Checks for the existence of a document. Returns true if it exists, false otherwise + * 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)} @@ -491,7 +491,7 @@ public final boolean exists(GetRequest getRequest, Header... headers) throws IOE } /** - * Asynchronously checks for the existence of a document. Returns true if it exists, false otherwise + * Asynchronously checks for the existence of a document. Returns true if it exists, false otherwise. * See Get API on elastic.co * @param getRequest the request * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -503,7 +503,7 @@ public final void existsAsync(GetRequest getRequest, RequestOptions options, Act } /** - * Asynchronously checks for the existence of a document. Returns true if it exists, false otherwise + * 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)} @@ -515,7 +515,7 @@ public final void existsAsync(GetRequest getRequest, ActionListener lis } /** - * Index a document using the Index API + * Index a document using the Index API. * See Index API on elastic.co * @param indexRequest the request * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -527,7 +527,7 @@ public final IndexResponse index(IndexRequest indexRequest, RequestOptions optio } /** - * Index a document using the Index API + * Index a document using the Index API. * * See Index API on elastic.co * @deprecated Prefer {@link #index(IndexRequest, RequestOptions)} @@ -538,7 +538,7 @@ public final IndexResponse index(IndexRequest indexRequest, Header... headers) t } /** - * Asynchronously index a document using the Index API + * Asynchronously index a document using the Index API. * See Index API on elastic.co * @param indexRequest the request * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -550,7 +550,7 @@ public final void indexAsync(IndexRequest indexRequest, RequestOptions options, } /** - * Asynchronously index a document using the Index API + * Asynchronously index a document using the Index API. * * See Index API on elastic.co * @deprecated Prefer {@link #indexAsync(IndexRequest, RequestOptions, ActionListener)} @@ -562,7 +562,7 @@ public final void indexAsync(IndexRequest indexRequest, ActionListenerUpdate API on elastic.co * @param updateRequest the request * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -574,7 +574,7 @@ public final UpdateResponse update(UpdateRequest updateRequest, RequestOptions o } /** - * Updates a document using the Update API + * Updates a document using the Update API. *

* See Update API on elastic.co * @deprecated Prefer {@link #update(UpdateRequest, RequestOptions)} @@ -585,7 +585,7 @@ public final UpdateResponse update(UpdateRequest updateRequest, Header... header } /** - * Asynchronously updates a document using the Update API + * Asynchronously updates a document using the Update API. * See Update API on elastic.co * @param updateRequest the request * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -597,7 +597,7 @@ public final void updateAsync(UpdateRequest updateRequest, RequestOptions option } /** - * Asynchronously updates a document using the Update API + * Asynchronously updates a document using the Update API. *

* See Update API on elastic.co * @deprecated Prefer {@link #updateAsync(UpdateRequest, RequestOptions, ActionListener)} @@ -609,7 +609,7 @@ public final void updateAsync(UpdateRequest updateRequest, ActionListenerDelete API on elastic.co * @param deleteRequest the reuqest * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -622,7 +622,7 @@ public final DeleteResponse delete(DeleteRequest deleteRequest, RequestOptions o } /** - * Deletes a document by id using the Delete API + * Deletes a document by id using the Delete API. * * See Delete API on elastic.co * @deprecated Prefer {@link #delete(DeleteRequest, RequestOptions)} @@ -634,7 +634,7 @@ public final DeleteResponse delete(DeleteRequest deleteRequest, Header... header } /** - * Asynchronously deletes a document by id using the Delete API + * Asynchronously deletes a document by id using the Delete API. * See Delete API on elastic.co * @param deleteRequest the request * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -646,7 +646,7 @@ public final void deleteAsync(DeleteRequest deleteRequest, RequestOptions option } /** - * Asynchronously deletes a document by id using the Delete API + * Asynchronously deletes a document by id using the Delete API. * * See Delete API on elastic.co * @deprecated Prefer {@link #deleteAsync(DeleteRequest, RequestOptions, ActionListener)} @@ -658,7 +658,7 @@ public final void deleteAsync(DeleteRequest deleteRequest, ActionListenerSearch API on elastic.co * @param searchRequest the request * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -670,7 +670,7 @@ public final SearchResponse search(SearchRequest searchRequest, RequestOptions o } /** - * Executes a search using the Search API + * Executes a search using the Search API. * * See Search API on elastic.co * @deprecated Prefer {@link #search(SearchRequest, RequestOptions)} @@ -681,7 +681,7 @@ public final SearchResponse search(SearchRequest searchRequest, Header... header } /** - * Asynchronously executes a search using the Search API + * Asynchronously executes a search using the Search API. * See Search API on elastic.co * @param searchRequest the request * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -693,7 +693,7 @@ public final void searchAsync(SearchRequest searchRequest, RequestOptions option } /** - * Asynchronously executes a search using the Search API + * Asynchronously executes a search using the Search API. * * See Search API on elastic.co * @deprecated Prefer {@link #searchAsync(SearchRequest, RequestOptions, ActionListener)} @@ -705,7 +705,7 @@ public final void searchAsync(SearchRequest searchRequest, ActionListenerMulti search API on * elastic.co * @param multiSearchRequest the request @@ -719,7 +719,7 @@ public final MultiSearchResponse multiSearch(MultiSearchRequest multiSearchReque } /** - * Executes a multi search using the msearch API + * Executes a multi search using the msearch API. * * See Multi search API on * elastic.co @@ -732,7 +732,7 @@ public final MultiSearchResponse multiSearch(MultiSearchRequest multiSearchReque } /** - * Asynchronously executes a multi search using the msearch API + * Asynchronously executes a multi search using the msearch API. * See Multi search API on * elastic.co * @param searchRequest the request @@ -746,7 +746,7 @@ public final void multiSearchAsync(MultiSearchRequest searchRequest, RequestOpti } /** - * Asynchronously executes a multi search using the msearch API + * Asynchronously executes a multi search using the msearch API. * * See Multi search API on * elastic.co @@ -759,7 +759,7 @@ public final void multiSearchAsync(MultiSearchRequest searchRequest, ActionListe } /** - * Executes a search using the Search Scroll API + * Executes a search using the Search Scroll API. * See Search Scroll * API on elastic.co * @param searchScrollRequest the request @@ -773,7 +773,7 @@ public final SearchResponse searchScroll(SearchScrollRequest searchScrollRequest } /** - * Executes a search using the Search Scroll API + * Executes a search using the Search Scroll API. * * See Search Scroll * API on elastic.co @@ -786,7 +786,7 @@ public final SearchResponse searchScroll(SearchScrollRequest searchScrollRequest } /** - * Asynchronously executes a search using the Search Scroll API + * Asynchronously executes a search using the Search Scroll API. * See Search Scroll * API on elastic.co * @param searchScrollRequest the request @@ -800,7 +800,7 @@ public final void searchScrollAsync(SearchScrollRequest searchScrollRequest, Req } /** - * Asynchronously executes a search using the Search Scroll API + * Asynchronously executes a search using the Search Scroll API. * * See Search Scroll * API on elastic.co @@ -814,7 +814,7 @@ public final void searchScrollAsync(SearchScrollRequest searchScrollRequest, } /** - * Clears one or more scroll ids using the Clear Scroll API + * Clears one or more scroll ids using the Clear Scroll API. * See * Clear Scroll API on elastic.co * @param clearScrollRequest the request @@ -828,7 +828,7 @@ public final ClearScrollResponse clearScroll(ClearScrollRequest clearScrollReque } /** - * Clears one or more scroll ids using the Clear Scroll API + * Clears one or more scroll ids using the Clear Scroll API. * * See * Clear Scroll API on elastic.co @@ -841,7 +841,7 @@ public final ClearScrollResponse clearScroll(ClearScrollRequest clearScrollReque } /** - * Asynchronously clears one or more scroll ids using the Clear Scroll API + * Asynchronously clears one or more scroll ids using the Clear Scroll API. * See * Clear Scroll API on elastic.co * @param clearScrollRequest the reuqest @@ -855,7 +855,7 @@ public final void clearScrollAsync(ClearScrollRequest clearScrollRequest, Reques } /** - * Asynchronously clears one or more scroll ids using the Clear Scroll API + * Asynchronously clears one or more scroll ids using the Clear Scroll API. * * See * Clear Scroll API on elastic.co @@ -884,7 +884,7 @@ public final SearchTemplateResponse searchTemplate(SearchTemplateRequest searchT } /** - * Asynchronously executes a request using the Search Template API + * Asynchronously executes a request using the Search Template API. * * See Search Template API * on elastic.co. 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 792b5bcbb2ad9..6e75352c73e18 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 @@ -40,7 +40,7 @@ public final class TasksClient { } /** - * Get current tasks using the Task Management API + * Get current tasks using the Task Management API. * See * Task Management API on elastic.co * @param request the request @@ -54,7 +54,7 @@ public ListTasksResponse list(ListTasksRequest request, RequestOptions options) } /** - * Asynchronously get current tasks using the Task Management API + * Asynchronously get current tasks using the Task Management API. * See * Task Management API on elastic.co * @param request the request From cabeea9d2ae029764bc51c4d928afd0d72973471 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 6 Jun 2018 14:39:35 +0200 Subject: [PATCH 6/7] fix compile errors --- .../client/documentation/IndicesClientDocumentationIT.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 d4ba3ce1c8516..2b81e4a4adce9 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 @@ -602,7 +602,7 @@ public void testGetMapping() throws IOException { // end::get-mapping-request-indicesOptions // tag::get-mapping-execute - GetMappingsResponse getMappingResponse = client.indices().getMappings(request); + GetMappingsResponse getMappingResponse = client.indices().getMappings(request, RequestOptions.DEFAULT); // end::get-mapping-execute // tag::get-mapping-response @@ -684,7 +684,7 @@ public void onFailure(Exception e) { }); // tag::get-mapping-execute-async - client.indices().getMappingsAsync(request, listener); // <1> + client.indices().getMappingsAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::get-mapping-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); From aee9dd3f3e69c6785c1614dffddde58d87054e3d Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 6 Jun 2018 20:53:25 +0200 Subject: [PATCH 7/7] update docs --- .../elasticsearch/client/ClusterClient.java | 4 +- .../elasticsearch/client/IndicesClient.java | 80 +++++++++---------- .../elasticsearch/client/IngestClient.java | 12 +-- .../client/RestHighLevelClient.java | 58 +++++++------- .../elasticsearch/client/SnapshotClient.java | 16 ++-- .../org/elasticsearch/client/TasksClient.java | 4 +- 6 files changed, 87 insertions(+), 87 deletions(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java index 288e0ab188e66..488579785e0f7 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java @@ -45,7 +45,7 @@ public final class ClusterClient { * See Cluster Update Settings * API on elastic.co * @param clusterUpdateSettingsRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -74,7 +74,7 @@ public ClusterUpdateSettingsResponse putSettings(ClusterUpdateSettingsRequest cl * See Cluster Update Settings * API on elastic.co * @param clusterUpdateSettingsRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void putSettingsAsync(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest, RequestOptions options, diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java index 52fefcf6e8eb0..fa7eb9ab9ec8a 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java @@ -79,7 +79,7 @@ public final class IndicesClient { * See * Delete Index API on elastic.co * @param deleteIndexRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -106,7 +106,7 @@ public DeleteIndexResponse delete(DeleteIndexRequest deleteIndexRequest, Header. * See * Delete Index API on elastic.co * @param deleteIndexRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void deleteAsync(DeleteIndexRequest deleteIndexRequest, RequestOptions options, ActionListener listener) { @@ -132,7 +132,7 @@ public void deleteAsync(DeleteIndexRequest deleteIndexRequest, ActionListener * Create Index API on elastic.co * @param createIndexRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -159,7 +159,7 @@ public CreateIndexResponse create(CreateIndexRequest createIndexRequest, Header. * See * Create Index API on elastic.co * @param createIndexRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void createAsync(CreateIndexRequest createIndexRequest, RequestOptions options, ActionListener listener) { @@ -185,7 +185,7 @@ public void createAsync(CreateIndexRequest createIndexRequest, ActionListener * Put Mapping API on elastic.co * @param putMappingRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -212,7 +212,7 @@ public PutMappingResponse putMapping(PutMappingRequest putMappingRequest, Header * See * Put Mapping API on elastic.co * @param putMappingRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void putMappingAsync(PutMappingRequest putMappingRequest, RequestOptions options, ActionListener listener) { @@ -239,7 +239,7 @@ public void putMappingAsync(PutMappingRequest putMappingRequest, ActionListener< * See * Get Mapping API on elastic.co * @param getMappingsRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -253,7 +253,7 @@ public GetMappingsResponse getMappings(GetMappingsRequest getMappingsRequest, Re * See * Get Mapping API on elastic.co * @param getMappingsRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void getMappingsAsync(GetMappingsRequest getMappingsRequest, RequestOptions options, @@ -267,7 +267,7 @@ public void getMappingsAsync(GetMappingsRequest getMappingsRequest, RequestOptio * See * Index Aliases API on elastic.co * @param indicesAliasesRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -295,7 +295,7 @@ public IndicesAliasesResponse updateAliases(IndicesAliasesRequest indicesAliases * See * Index Aliases API on elastic.co * @param indicesAliasesRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void updateAliasesAsync(IndicesAliasesRequest indicesAliasesRequest, RequestOptions options, @@ -324,7 +324,7 @@ public void updateAliasesAsync(IndicesAliasesRequest indicesAliasesRequest, Acti * See * Open Index API on elastic.co * @param openIndexRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -351,7 +351,7 @@ public OpenIndexResponse open(OpenIndexRequest openIndexRequest, Header... heade * See * Open Index API on elastic.co * @param openIndexRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void openAsync(OpenIndexRequest openIndexRequest, RequestOptions options, ActionListener listener) { @@ -377,7 +377,7 @@ public void openAsync(OpenIndexRequest openIndexRequest, ActionListener * Close Index API on elastic.co * @param closeIndexRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -404,7 +404,7 @@ public CloseIndexResponse close(CloseIndexRequest closeIndexRequest, Header... h * See * Close Index API on elastic.co * @param closeIndexRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void closeAsync(CloseIndexRequest closeIndexRequest, RequestOptions options, ActionListener listener) { @@ -431,7 +431,7 @@ public void closeAsync(CloseIndexRequest closeIndexRequest, ActionListener * Indices Aliases API on elastic.co * @param getAliasesRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request */ @@ -458,7 +458,7 @@ public boolean existsAlias(GetAliasesRequest getAliasesRequest, Header... header * See * Indices Aliases API on elastic.co * @param getAliasesRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void existsAliasAsync(GetAliasesRequest getAliasesRequest, RequestOptions options, ActionListener listener) { @@ -483,7 +483,7 @@ public void existsAliasAsync(GetAliasesRequest getAliasesRequest, ActionListener * Refresh one or more indices using the Refresh API. * See Refresh API on elastic.co * @param refreshRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -508,7 +508,7 @@ public RefreshResponse refresh(RefreshRequest refreshRequest, Header... headers) * Asynchronously refresh one or more indices using the Refresh API. * See Refresh API on elastic.co * @param refreshRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void refreshAsync(RefreshRequest refreshRequest, RequestOptions options, ActionListener listener) { @@ -532,7 +532,7 @@ public void refreshAsync(RefreshRequest refreshRequest, ActionListener Flush API on elastic.co * @param flushRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -557,7 +557,7 @@ public FlushResponse flush(FlushRequest flushRequest, Header... headers) throws * Asynchronously flush one or more indices using the Flush API. * See Flush API on elastic.co * @param flushRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void flushAsync(FlushRequest flushRequest, RequestOptions options, ActionListener listener) { @@ -582,7 +582,7 @@ public void flushAsync(FlushRequest flushRequest, ActionListener * See * Synced flush API on elastic.co * @param syncedFlushRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -596,7 +596,7 @@ public SyncedFlushResponse flushSynced(SyncedFlushRequest syncedFlushRequest, Re * See * Synced flush API on elastic.co * @param syncedFlushRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void flushSyncedAsync(SyncedFlushRequest syncedFlushRequest, RequestOptions options, @@ -610,7 +610,7 @@ public void flushSyncedAsync(SyncedFlushRequest syncedFlushRequest, RequestOptio * See * Indices Get Settings API on elastic.co * @param getSettingsRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -624,7 +624,7 @@ public GetSettingsResponse getSettings(GetSettingsRequest getSettingsRequest, Re * See * Indices Get Settings API on elastic.co * @param getSettingsRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void getSettingsAsync(GetSettingsRequest getSettingsRequest, RequestOptions options, @@ -638,7 +638,7 @@ public void getSettingsAsync(GetSettingsRequest getSettingsRequest, RequestOptio * See * Force Merge API on elastic.co * @param forceMergeRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -665,7 +665,7 @@ public ForceMergeResponse forceMerge(ForceMergeRequest forceMergeRequest, Header * See * Force Merge API on elastic.co * @param forceMergeRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void forceMergeAsync(ForceMergeRequest forceMergeRequest, RequestOptions options, ActionListener listener) { @@ -691,7 +691,7 @@ public void forceMergeAsync(ForceMergeRequest forceMergeRequest, ActionListener< * See * Clear Cache API on elastic.co * @param clearIndicesCacheRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -719,7 +719,7 @@ public ClearIndicesCacheResponse clearCache(ClearIndicesCacheRequest clearIndice * See * Clear Cache API on elastic.co * @param clearIndicesCacheRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void clearCacheAsync(ClearIndicesCacheRequest clearIndicesCacheRequest, RequestOptions options, @@ -747,7 +747,7 @@ public void clearCacheAsync(ClearIndicesCacheRequest clearIndicesCacheRequest, A * See * Indices Exists API on elastic.co * @param request the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request */ @@ -784,7 +784,7 @@ public boolean exists(GetIndexRequest request, Header... headers) throws IOExcep * See * Indices Exists API on elastic.co * @param request the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void existsAsync(GetIndexRequest request, RequestOptions options, ActionListener listener) { @@ -822,7 +822,7 @@ public void existsAsync(GetIndexRequest request, ActionListener listene * See * Shrink Index API on elastic.co * @param resizeRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -849,7 +849,7 @@ public ResizeResponse shrink(ResizeRequest resizeRequest, Header... headers) thr * See * Shrink Index API on elastic.co * @param resizeRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void shrinkAsync(ResizeRequest resizeRequest, RequestOptions options, ActionListener listener) { @@ -875,7 +875,7 @@ public void shrinkAsync(ResizeRequest resizeRequest, ActionListener * Split Index API on elastic.co * @param resizeRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -902,7 +902,7 @@ public ResizeResponse split(ResizeRequest resizeRequest, Header... headers) thro * See * Split Index API on elastic.co * @param resizeRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void splitAsync(ResizeRequest resizeRequest, RequestOptions options, ActionListener listener) { @@ -928,7 +928,7 @@ public void splitAsync(ResizeRequest resizeRequest, ActionListener * Rollover Index API on elastic.co * @param rolloverRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -955,7 +955,7 @@ public RolloverResponse rollover(RolloverRequest rolloverRequest, Header... head * See * Rollover Index API on elastic.co * @param rolloverRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void rolloverAsync(RolloverRequest rolloverRequest, RequestOptions options, ActionListener listener) { @@ -981,7 +981,7 @@ public void rolloverAsync(RolloverRequest rolloverRequest, ActionListener Update Indices Settings * API on elastic.co * @param updateSettingsRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -1008,7 +1008,7 @@ public UpdateSettingsResponse putSettings(UpdateSettingsRequest updateSettingsRe * See Update Indices Settings * API on elastic.co * @param updateSettingsRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void putSettingsAsync(UpdateSettingsRequest updateSettingsRequest, RequestOptions options, @@ -1036,7 +1036,7 @@ public void putSettingsAsync(UpdateSettingsRequest updateSettingsRequest, Action * See Index Templates API * on elastic.co * @param putIndexTemplateRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -1051,7 +1051,7 @@ public PutIndexTemplateResponse putTemplate(PutIndexTemplateRequest putIndexTemp * See Index Templates API * on elastic.co * @param putIndexTemplateRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void putTemplateAsync(PutIndexTemplateRequest putIndexTemplateRequest, RequestOptions options, diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java index bb7c4a9457b3c..5c5a82b52f438 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java @@ -48,7 +48,7 @@ public final class IngestClient { * See * Put Pipeline API on elastic.co * @param request the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -62,7 +62,7 @@ public WritePipelineResponse putPipeline(PutPipelineRequest request, RequestOpti * See * Put Pipeline API on elastic.co * @param request the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void putPipelineAsync(PutPipelineRequest request, RequestOptions options, ActionListener listener) { @@ -75,7 +75,7 @@ public void putPipelineAsync(PutPipelineRequest request, RequestOptions options, * See * Get Pipeline API on elastic.co * @param request the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -89,7 +89,7 @@ public GetPipelineResponse getPipeline(GetPipelineRequest request, RequestOption * See * Get Pipeline API on elastic.co * @param request the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void getPipelineAsync(GetPipelineRequest request, RequestOptions options, ActionListener listener) { @@ -103,7 +103,7 @@ public void getPipelineAsync(GetPipelineRequest request, RequestOptions options, * * Delete Pipeline API on elastic.co * @param request the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -118,7 +118,7 @@ public WritePipelineResponse deletePipeline(DeletePipelineRequest request, Reque * * Delete Pipeline API on elastic.co * @param request the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void deletePipelineAsync(DeletePipelineRequest request, RequestOptions options, ActionListener listener) { 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 48955bf2a702a..8980508c48738 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 @@ -288,7 +288,7 @@ public final TasksClient tasks() { * Executes a bulk request using the Bulk API. * See Bulk API on elastic.co * @param bulkRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -311,7 +311,7 @@ public final BulkResponse bulk(BulkRequest bulkRequest, Header... headers) throw * Asynchronously executes a bulk request using the Bulk API. * See Bulk API on elastic.co * @param bulkRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public final void bulkAsync(BulkRequest bulkRequest, RequestOptions options, ActionListener listener) { @@ -331,7 +331,7 @@ public final void bulkAsync(BulkRequest bulkRequest, ActionListenertrue if the ping succeeded, false otherwise * @throws IOException in case there is a problem sending the request */ @@ -352,7 +352,7 @@ public final boolean ping(Header... headers) throws IOException { /** * Get the cluster info otherwise provided when sending an HTTP request to '/' - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -375,7 +375,7 @@ public final MainResponse info(Header... headers) throws IOException { * Retrieves a document by id using the Get API. * See Get API on elastic.co * @param getRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -398,7 +398,7 @@ public final GetResponse get(GetRequest getRequest, Header... headers) throws IO * Asynchronously retrieves a document by id using the Get API. * See Get API on elastic.co * @param getRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public final void getAsync(GetRequest getRequest, RequestOptions options, ActionListener listener) { @@ -422,7 +422,7 @@ public final void getAsync(GetRequest getRequest, ActionListener li * Retrieves multiple documents by id using the Multi Get API. * See Multi Get API on elastic.co * @param multiGetRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -447,7 +447,7 @@ public final MultiGetResponse multiGet(MultiGetRequest multiGetRequest, Header.. * Asynchronously retrieves multiple documents by id using the Multi Get API. * See Multi Get API on elastic.co * @param multiGetRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public final void multiGetAsync(MultiGetRequest multiGetRequest, RequestOptions options, ActionListener listener) { @@ -471,7 +471,7 @@ public final void multiGetAsync(MultiGetRequest multiGetRequest, ActionListener< * Checks for the existence of a document. Returns true if it exists, false otherwise. * See Get API on elastic.co * @param getRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return true if the document exists, false otherwise * @throws IOException in case there is a problem sending the request */ @@ -494,7 +494,7 @@ public final boolean exists(GetRequest getRequest, Header... headers) throws IOE * Asynchronously checks for the existence of a document. Returns true if it exists, false otherwise. * See Get API on elastic.co * @param getRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public final void existsAsync(GetRequest getRequest, RequestOptions options, ActionListener listener) { @@ -518,7 +518,7 @@ public final void existsAsync(GetRequest getRequest, ActionListener lis * Index a document using the Index API. * See Index API on elastic.co * @param indexRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -541,7 +541,7 @@ public final IndexResponse index(IndexRequest indexRequest, Header... headers) t * Asynchronously index a document using the Index API. * See Index API on elastic.co * @param indexRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public final void indexAsync(IndexRequest indexRequest, RequestOptions options, ActionListener listener) { @@ -565,7 +565,7 @@ public final void indexAsync(IndexRequest indexRequest, ActionListenerUpdate API on elastic.co * @param updateRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -588,7 +588,7 @@ public final UpdateResponse update(UpdateRequest updateRequest, Header... header * Asynchronously updates a document using the Update API. * See Update API on elastic.co * @param updateRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public final void updateAsync(UpdateRequest updateRequest, RequestOptions options, ActionListener listener) { @@ -612,7 +612,7 @@ public final void updateAsync(UpdateRequest updateRequest, ActionListenerDelete API on elastic.co * @param deleteRequest the reuqest - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -637,7 +637,7 @@ public final DeleteResponse delete(DeleteRequest deleteRequest, Header... header * Asynchronously deletes a document by id using the Delete API. * See Delete API on elastic.co * @param deleteRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public final void deleteAsync(DeleteRequest deleteRequest, RequestOptions options, ActionListener listener) { @@ -661,7 +661,7 @@ public final void deleteAsync(DeleteRequest deleteRequest, ActionListenerSearch API on elastic.co * @param searchRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -684,7 +684,7 @@ public final SearchResponse search(SearchRequest searchRequest, Header... header * Asynchronously executes a search using the Search API. * See Search API on elastic.co * @param searchRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public final void searchAsync(SearchRequest searchRequest, RequestOptions options, ActionListener listener) { @@ -709,7 +709,7 @@ public final void searchAsync(SearchRequest searchRequest, ActionListenerMulti search API on * elastic.co * @param multiSearchRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -736,7 +736,7 @@ public final MultiSearchResponse multiSearch(MultiSearchRequest multiSearchReque * See Multi search API on * elastic.co * @param searchRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public final void multiSearchAsync(MultiSearchRequest searchRequest, RequestOptions options, @@ -763,7 +763,7 @@ public final void multiSearchAsync(MultiSearchRequest searchRequest, ActionListe * See Search Scroll * API on elastic.co * @param searchScrollRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -790,7 +790,7 @@ public final SearchResponse searchScroll(SearchScrollRequest searchScrollRequest * See Search Scroll * API on elastic.co * @param searchScrollRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public final void searchScrollAsync(SearchScrollRequest searchScrollRequest, RequestOptions options, @@ -818,7 +818,7 @@ public final void searchScrollAsync(SearchScrollRequest searchScrollRequest, * See * Clear Scroll API on elastic.co * @param clearScrollRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -845,7 +845,7 @@ public final ClearScrollResponse clearScroll(ClearScrollRequest clearScrollReque * See * Clear Scroll API on elastic.co * @param clearScrollRequest the reuqest - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public final void clearScrollAsync(ClearScrollRequest clearScrollRequest, RequestOptions options, @@ -873,7 +873,7 @@ public final void clearScrollAsync(ClearScrollRequest clearScrollRequest, * See Search Template API * on elastic.co. * @param searchTemplateRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -900,7 +900,7 @@ public final void searchTemplateAsync(SearchTemplateRequest searchTemplateReques * See Ranking Evaluation API * on elastic.co * @param rankEvalRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -927,7 +927,7 @@ public final RankEvalResponse rankEval(RankEvalRequest rankEvalRequest, Header.. * See Ranking Evaluation API * on elastic.co * @param rankEvalRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public final void rankEvalAsync(RankEvalRequest rankEvalRequest, RequestOptions options, ActionListener listener) { @@ -953,7 +953,7 @@ public final void rankEvalAsync(RankEvalRequest rankEvalRequest, ActionListener< * See Field Capabilities API * on elastic.co. * @param fieldCapabilitiesRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -968,7 +968,7 @@ public final FieldCapabilitiesResponse fieldCaps(FieldCapabilitiesRequest fieldC * See Field Capabilities API * on elastic.co. * @param fieldCapabilitiesRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public final void fieldCapsAsync(FieldCapabilitiesRequest fieldCapabilitiesRequest, RequestOptions options, diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/SnapshotClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/SnapshotClient.java index 56ce007073cae..b7cd2d52732cc 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/SnapshotClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/SnapshotClient.java @@ -51,7 +51,7 @@ public final class SnapshotClient { * See Snapshot and Restore * API on elastic.co * @param getRepositoriesRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -67,7 +67,7 @@ public GetRepositoriesResponse getRepositories(GetRepositoriesRequest getReposit * See Snapshot and Restore * API on elastic.co * @param getRepositoriesRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void getRepositoriesAsync(GetRepositoriesRequest getRepositoriesRequest, RequestOptions options, @@ -81,7 +81,7 @@ public void getRepositoriesAsync(GetRepositoriesRequest getRepositoriesRequest, * See Snapshot and Restore * API on elastic.co * @param putRepositoryRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -95,7 +95,7 @@ public PutRepositoryResponse createRepository(PutRepositoryRequest putRepository * See Snapshot and Restore * API on elastic.co * @param putRepositoryRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void createRepositoryAsync(PutRepositoryRequest putRepositoryRequest, RequestOptions options, @@ -109,7 +109,7 @@ public void createRepositoryAsync(PutRepositoryRequest putRepositoryRequest, Req * See Snapshot and Restore * API on elastic.co * @param deleteRepositoryRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -124,7 +124,7 @@ public DeleteRepositoryResponse deleteRepository(DeleteRepositoryRequest deleteR * See Snapshot and Restore * API on elastic.co * @param deleteRepositoryRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void deleteRepositoryAsync(DeleteRepositoryRequest deleteRepositoryRequest, RequestOptions options, @@ -138,7 +138,7 @@ public void deleteRepositoryAsync(DeleteRepositoryRequest deleteRepositoryReques * See Snapshot and Restore * API on elastic.co * @param verifyRepositoryRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -153,7 +153,7 @@ public VerifyRepositoryResponse verifyRepository(VerifyRepositoryRequest verifyR * See Snapshot and Restore * API on elastic.co * @param verifyRepositoryRequest the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void verifyRepositoryAsync(VerifyRepositoryRequest verifyRepositoryRequest, 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 6e75352c73e18..f4a76e78b946b 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 @@ -44,7 +44,7 @@ public final class TasksClient { * See * Task Management API on elastic.co * @param request the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ @@ -58,7 +58,7 @@ public ListTasksResponse list(ListTasksRequest request, RequestOptions options) * See * Task Management API on elastic.co * @param request the request - * @param options the request options (e.g. headers), or {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized * @param listener the listener to be notified upon request completion */ public void listAsync(ListTasksRequest request, RequestOptions options, ActionListener listener) {