diff --git a/build.gradle b/build.gradle
index 05ad5479e8d..015db80d325 100644
--- a/build.gradle
+++ b/build.gradle
@@ -205,9 +205,9 @@ subprojects {
"org.elasticsearch.gradle:build-tools:${version}": ':build-tools',
"org.elasticsearch:rest-api-spec:${version}": ':rest-api-spec',
"org.elasticsearch:elasticsearch:${version}": ':server',
- "org.elasticsearch:elasticsearch-cli:${version}": ':server:cli',
- "org.elasticsearch:elasticsearch-core:${version}": ':libs:elasticsearch-core',
- "org.elasticsearch:elasticsearch-nio:${version}": ':libs:elasticsearch-nio',
+ "org.elasticsearch:elasticsearch-cli:${version}": ':libs:cli',
+ "org.elasticsearch:elasticsearch-core:${version}": ':libs:core',
+ "org.elasticsearch:elasticsearch-nio:${version}": ':libs:nio',
"org.elasticsearch:elasticsearch-x-content:${version}": ':libs:x-content',
"org.elasticsearch:elasticsearch-secure-sm:${version}": ':libs:secure-sm',
"org.elasticsearch.client:elasticsearch-rest-client:${version}": ':client:rest',
@@ -226,6 +226,7 @@ subprojects {
"org.elasticsearch.distribution.deb:elasticsearch:${version}": ':distribution:packages:deb',
"org.elasticsearch.distribution.deb:elasticsearch-oss:${version}": ':distribution:packages:oss-deb',
"org.elasticsearch.test:logger-usage:${version}": ':test:logger-usage',
+ "org.elasticsearch.xpack.test:feature-aware:${version}": ':x-pack:test:feature-aware',
// for transport client
"org.elasticsearch.plugin:transport-netty4-client:${version}": ':modules:transport-netty4',
"org.elasticsearch.plugin:reindex-client:${version}": ':modules:reindex',
@@ -311,7 +312,15 @@ gradle.projectsEvaluated {
// :test:framework:test cannot run before and after :server:test
return
}
- configurations.all {
+ configurations.all { Configuration configuration ->
+ /*
+ * The featureAwarePlugin configuration has a dependency on x-pack:plugin:core and x-pack:plugin:core has a dependency on the
+ * featureAwarePlugin configuration. The below task ordering logic would force :x-pack:plugin:core:test
+ * :x-pack:test:feature-aware:test to depend on each other circularly. We break that cycle here.
+ */
+ if (configuration.name == "featureAwarePlugin") {
+ return
+ }
dependencies.all { Dependency dep ->
Project upstreamProject = dependencyToProject(dep)
if (upstreamProject != null) {
diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterConfiguration.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterConfiguration.groovy
index cd6c7c36ee6..5c363ac043a 100644
--- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterConfiguration.groovy
+++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterConfiguration.groovy
@@ -87,8 +87,9 @@ class ClusterConfiguration {
* A closure to call which returns the unicast host to connect to for cluster formation.
*
* This allows multi node clusters, or a new cluster to connect to an existing cluster.
- * The closure takes two arguments, the NodeInfo for the first node in the cluster, and
- * an AntBuilder which may be used to wait on conditions before returning.
+ * The closure takes three arguments, the NodeInfo for the first node in the cluster,
+ * the NodeInfo for the node current being configured, an AntBuilder which may be used
+ * to wait on conditions before returning.
*/
@Input
Closure unicastTransportUri = { NodeInfo seedNode, NodeInfo node, AntBuilder ant ->
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 f3c84db79d6..488579785e0 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,11 +41,28 @@ 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
+ * @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
+ */
+ 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,
@@ -53,11 +70,26 @@ public final class ClusterClient {
}
/**
- * 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
+ * @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,
+ 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 d51a92ea00f..fa7eb9ab9ec 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.OpenIndexRequest;
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;
@@ -76,66 +75,159 @@ 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
+ * @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
+ */
+ 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);
}
/**
- * 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
+ * @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) {
+ 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);
}
/**
- * Creates an index using the Create Index API
+ * 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), 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
+ */
+ 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);
}
/**
- * 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
+ * @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) {
+ 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);
}
/**
- * 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
+ * @param putMappingRequest the request
+ * @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
+ */
+ 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);
}
/**
- * 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
+ * @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) {
+ 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,
@@ -143,242 +235,507 @@ public final class IndicesClient {
}
/**
- * 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
+ * @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
*/
- 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
- *
+ * 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), 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, 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
+ * Updates aliases using the Index Aliases API.
+ * See
+ * Index Aliases API on elastic.co
+ * @param indicesAliasesRequest the request
+ * @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
+ */
+ 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);
}
/**
- * 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
+ * @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,
+ 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);
}
/**
- * 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
+ * @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
+ */
+ 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);
}
/**
- * 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
+ * @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) {
+ 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);
}
/**
- * Closes an index using the Close Index API
+ * 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), 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
+ */
+ 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);
}
/**
- * 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
+ * @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) {
+ 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);
}
/**
- * 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
+ * @param getAliasesRequest the request
+ * @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
+ */
+ 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);
}
/**
- * 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
+ * @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) {
+ 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);
}
/**
- * 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), 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
+ */
+ 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);
}
/**
- * 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), 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) {
+ 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);
}
/**
- * Flush one or more indices using the Flush API
+ * 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), 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
+ */
+ 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);
}
/**
- * 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), 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) {
+ 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)}
*/
+ @Deprecated
public void flushAsync(FlushRequest flushRequest, ActionListener listener, Header... headers) {
restHighLevelClient.performRequestAsyncAndParseEntity(flushRequest, RequestConverters::flush, FlushResponse::fromXContent,
listener, emptySet(), headers);
}
- /** Initiate a synced flush manually using the synced flush API
- *
- * 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);
- }
-
/**
- * Asynchronously 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
+ * @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
*/
- public void flushSyncedAsync(SyncedFlushRequest syncedFlushRequest, ActionListener listener, Header... headers) {
- restHighLevelClient.performRequestAsyncAndParseEntity(syncedFlushRequest, RequestConverters::flushSynced,
- SyncedFlushResponse::fromXContent, listener, emptySet(), headers);
+ public SyncedFlushResponse flushSynced(SyncedFlushRequest syncedFlushRequest, RequestOptions options) throws IOException {
+ return restHighLevelClient.performRequestAndParseEntity(syncedFlushRequest, RequestConverters::flushSynced, options,
+ SyncedFlushResponse::fromXContent, emptySet());
}
+ /**
+ * 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), 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,
+ ActionListener listener) {
+ restHighLevelClient.performRequestAsyncAndParseEntity(syncedFlushRequest, RequestConverters::flushSynced, options,
+ SyncedFlushResponse::fromXContent, listener, emptySet());
+ }
/**
- * 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
+ * @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
*/
- 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());
}
/**
- * 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
+ * @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, 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());
}
/**
- * 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
+ * @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
+ */
+ 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);
}
/**
- * 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
+ * @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) {
+ 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);
}
/**
- * 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
+ * @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
+ */
+ 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);
}
/**
- * 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
+ * @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,
+ 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,
@@ -387,17 +744,57 @@ public final class IndicesClient {
/**
* 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), use {@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, 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
+ * @param request the request
+ * @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) {
+ restHighLevelClient.performRequestAsync(
+ request,
+ RequestConverters::indicesExist,
+ options,
+ RestHighLevelClient::convertExistsResponse,
+ listener,
+ Collections.emptySet()
);
}
@@ -406,7 +803,9 @@ public final class IndicesClient {
*
* 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,
@@ -419,88 +818,213 @@ public final class IndicesClient {
}
/**
- * 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
+ * @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
+ */
+ 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);
}
/**
- * 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
+ * @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) {
+ 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);
}
/**
- * Splits an index using the Split Index API
+ * 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), 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
+ */
+ 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);
}
/**
- * 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
+ * @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) {
+ 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);
}
/**
- * 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
+ * @param rolloverRequest the request
+ * @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
+ */
+ 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);
}
/**
- * 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
+ * @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) {
+ 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);
}
/**
- * 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
+ * @param updateSettingsRequest the request
+ * @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
+ */
+ 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);
}
/**
- * 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
+ * @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,
+ 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 #putSettingsAsync(UpdateSettingsRequest, RequestOptions, ActionListener)}
*/
+ @Deprecated
public void putSettingsAsync(UpdateSettingsRequest updateSettingsRequest, ActionListener listener,
Header... headers) {
restHighLevelClient.performRequestAsyncAndParseEntity(updateSettingsRequest, RequestConverters::indexPutSettings,
@@ -508,25 +1032,31 @@ public final class IndicesClient {
}
/**
- * 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
+ * @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
*/
- 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());
}
/**
- * 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
+ * @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,
- 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 72b1813f939..5c5a82b52f4 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;
@@ -45,70 +44,85 @@ 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
+ * @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
*/
- 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());
}
/**
- * 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
+ * @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, 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());
}
/**
- * Get an existing pipeline
- *
+ * Get an existing pipeline.
* See
* Get Pipeline API on elastic.co
+ * @param request the request
+ * @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
*/
- 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());
}
/**
- * Asynchronously get an existing pipeline
- *
+ * Asynchronously get an existing pipeline.
* See
* Get Pipeline API on elastic.co
+ * @param request the request
+ * @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, 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());
}
/**
- * Delete an existing pipeline
- *
+ * Delete an existing pipeline.
* See
*
* Delete Pipeline API on elastic.co
+ * @param request the request
+ * @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
*/
- 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());
}
/**
- * Asynchronously delete an existing pipeline
- *
+ * Asynchronously delete an existing pipeline.
* See
*
* Delete Pipeline API on elastic.co
+ * @param request the request
+ * @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, 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/RequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java
index e5a45e19fe0..96fb7e59de3 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
@@ -29,6 +29,7 @@ import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.ContentType;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.action.DocWriteRequest;
+import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest;
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest;
import org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest;
import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesRequest;
@@ -108,6 +109,17 @@ final class RequestConverters {
// Contains only status utility methods
}
+ static Request cancelTasks(CancelTasksRequest cancelTasksRequest) {
+ Request request = new Request(HttpPost.METHOD_NAME, "/_tasks/_cancel");
+ Params params = new Params(request);
+ params.withTimeout(cancelTasksRequest.getTimeout())
+ .withTaskId(cancelTasksRequest.getTaskId())
+ .withNodes(cancelTasksRequest.getNodes())
+ .withParentTaskId(cancelTasksRequest.getParentTaskId())
+ .withActions(cancelTasksRequest.getActions());
+ return request;
+ }
+
static Request delete(DeleteRequest deleteRequest) {
String endpoint = endpoint(deleteRequest.index(), deleteRequest.type(), deleteRequest.id());
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
@@ -710,7 +722,7 @@ final class RequestConverters {
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();
@@ -1070,6 +1082,13 @@ final class RequestConverters {
return this;
}
+ Params withTaskId(TaskId taskId) {
+ if (taskId != null && taskId.isSet()) {
+ return putParam("task_id", taskId.toString());
+ }
+ return this;
+ }
+
Params withParentTaskId(TaskId parentTaskId) {
if (parentTaskId != null && parentTaskId.isSet()) {
return putParam("parent_task_id", parentTaskId.toString());
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 a9587b73c19..8980508c487 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,16 +285,19 @@ public class RestHighLevelClient implements Closeable {
}
/**
- * 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), 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
*/
public final BulkResponse bulk(BulkRequest bulkRequest, RequestOptions options) throws IOException {
return performRequestAndParseEntity(bulkRequest, RequestConverters::bulk, options, BulkResponse::fromXContent, emptySet());
}
/**
- * 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)}
@@ -305,16 +308,18 @@ public class RestHighLevelClient implements Closeable {
}
/**
- * 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), 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) {
performRequestAsyncAndParseEntity(bulkRequest, RequestConverters::bulk, options, BulkResponse::fromXContent, listener, emptySet());
}
/**
- * 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)}
@@ -326,194 +331,482 @@ public class RestHighLevelClient implements Closeable {
/**
* Pings the remote Elasticsearch cluster and returns true if the ping succeeded, false otherwise
+ * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
+ * @return true
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,
+ emptySet());
+ }
+
+ /**
+ * Pings the remote Elasticsearch cluster and returns true if the ping succeeded, false otherwise
+ * @deprecated Prefer {@link #ping(RequestOptions)}
+ */
+ @Deprecated
public final boolean ping(Header... headers) throws IOException {
return performRequest(new MainRequest(), (request) -> RequestConverters.ping(), RestHighLevelClient::convertExistsResponse,
emptySet(), headers);
}
/**
- * Get the cluster info otherwise provided when sending an HTTP request to port 9200
+ * Get the cluster info otherwise provided when sending an HTTP request to '/'
+ * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
+ * @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,
+ MainResponse::fromXContent, emptySet());
+ }
+
+ /**
+ * Get the cluster info otherwise provided when sending an HTTP request to port 9200
+ * @deprecated Prefer {@link #info(RequestOptions)}
+ */
+ @Deprecated
public final MainResponse info(Header... headers) throws IOException {
return performRequestAndParseEntity(new MainRequest(), (request) -> RequestConverters.info(),
MainResponse::fromXContent, emptySet(), headers);
}
/**
- * Retrieves a document by id using the Get API
+ * 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), 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
+ */
+ 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);
}
/**
- * 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), 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) {
+ 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);
}
/**
- * 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), 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
+ */
+ 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);
}
/**
- * 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), 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) {
+ 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);
}
/**
- * 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), 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
+ */
+ 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);
}
/**
- * 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), 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) {
+ 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);
}
/**
- * 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), 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
+ */
+ 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);
}
/**
- * 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), 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) {
+ 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);
}
/**
- * Updates a document using the Update API
+ * 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), 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
+ */
+ 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);
}
/**
- * 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), 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) {
+ 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);
}
/**
- * Deletes a document by id using the Delete API
+ * Deletes a document by id using the Delete API.
+ * See Delete API on elastic.co
+ * @param deleteRequest the reuqest
+ * @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
+ */
+ 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);
}
/**
- * 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), 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, ActionListener listener, Header... headers) {
- performRequestAsyncAndParseEntity(deleteRequest, RequestConverters::delete, DeleteResponse::fromXContent, listener,
- Collections.singleton(404), headers);
+ public final void deleteAsync(DeleteRequest deleteRequest, RequestOptions options, ActionListener listener) {
+ performRequestAsyncAndParseEntity(deleteRequest, RequestConverters::delete, options, DeleteResponse::fromXContent, listener,
+ Collections.singleton(404));
}
/**
- * Executes a search using the Search API
+ * Asynchronously deletes a document by id using the Delete API.
+ *
+ * See Delete API on elastic.co
+ * @deprecated Prefer {@link #deleteAsync(DeleteRequest, RequestOptions, ActionListener)}
+ */
+ @Deprecated
+ public final void deleteAsync(DeleteRequest deleteRequest, ActionListener listener, Header... headers) {
+ performRequestAsyncAndParseEntity(deleteRequest, RequestConverters::delete, DeleteResponse::fromXContent, listener,
+ Collections.singleton(404), headers);
+ }
+
+ /**
+ * Executes a search request using the Search API.
+ * See Search API on elastic.co
+ * @param searchRequest the request
+ * @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
+ */
+ 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);
}
/**
- * 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), 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) {
+ 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);
}
/**
- * Executes a multi search using the msearch API
+ * Executes a multi search using the msearch API.
+ * See Multi search API on
+ * elastic.co
+ * @param multiSearchRequest the request
+ * @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
+ */
+ 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);
}
/**
- * 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
+ * @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,
+ 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)}
*/
+ @Deprecated
public final void multiSearchAsync(MultiSearchRequest searchRequest, ActionListener listener, Header... headers) {
performRequestAsyncAndParseEntity(searchRequest, RequestConverters::multiSearch, MultiSearchResponse::fromXContext, listener,
emptySet(), headers);
}
/**
- * Executes a search using the Search Scroll API
+ * 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), 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
+ */
+ 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);
}
/**
- * 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
+ * @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,
+ 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,
@@ -521,22 +814,54 @@ public class RestHighLevelClient implements Closeable {
}
/**
- * 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
+ * @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
+ */
+ 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);
}
/**
- * 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
+ * @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,
+ 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,
@@ -545,47 +870,79 @@ public class RestHighLevelClient implements Closeable {
/**
* 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), 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
*/
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());
}
/**
- * 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 .
*/
- 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());
}
+ /**
+ * 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), 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
+ */
+ 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);
}
+ /**
+ * 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), 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) {
+ 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);
@@ -593,27 +950,31 @@ public class RestHighLevelClient implements Closeable {
/**
* 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), 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
*/
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());
}
/**
* 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), 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,
- 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 104bc912711..b7cd2d52732 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;
@@ -49,97 +48,117 @@ 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), 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
*/
- 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());
}
/**
* 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), 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,
- 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());
}
/**
* Creates a snapshot repository.
- *
* See Snapshot and Restore
* API on elastic.co
+ * @param putRepositoryRequest the request
+ * @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
*/
- 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());
}
/**
* 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), 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,
- 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());
}
/**
* Deletes a snapshot repository.
- *
* See Snapshot and Restore
* API on elastic.co
+ * @param deleteRepositoryRequest the request
+ * @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
*/
- 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());
}
/**
* 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), 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,
- 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());
}
/**
* Verifies a snapshot repository.
- *
* See Snapshot and Restore
* API on elastic.co
+ * @param verifyRepositoryRequest the request
+ * @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
*/
- 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());
}
/**
* 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), 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,
- 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 214f1e7884a..f8f03d7f7d2 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,8 +19,9 @@
package org.elasticsearch.client;
-import org.apache.http.Header;
import org.elasticsearch.action.ActionListener;
+import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest;
+import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksResponse;
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest;
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse;
@@ -33,7 +34,7 @@ import static java.util.Collections.emptySet;
*
* See Task Management API on elastic.co
*/
-public class TasksClient {
+public final class TasksClient {
private final RestHighLevelClient restHighLevelClient;
TasksClient(RestHighLevelClient restHighLevelClient) {
@@ -41,24 +42,70 @@ public 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
+ * @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
*/
- 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());
}
/**
- * 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
+ * @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, 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());
+ }
+
+ /**
+ * Cancel one or more cluster tasks using the Task Management API.
+ *
+ * See
+ * Task Management API on elastic.co
+ * @param cancelTasksRequest the request
+ * @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
+ *
+ */
+ public CancelTasksResponse cancel(CancelTasksRequest cancelTasksRequest, RequestOptions options ) throws IOException {
+ return restHighLevelClient.performRequestAndParseEntity(
+ cancelTasksRequest,
+ RequestConverters::cancelTasks,
+ options,
+ parser -> CancelTasksResponse.fromXContent(parser),
+ emptySet()
+ );
+ }
+
+ /**
+ * Asynchronously cancel one or more cluster tasks using the Task Management API.
+ *
+ * See
+ * Task Management API on elastic.co
+ * @param cancelTasksRequest the request
+ * @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 cancelAsync(CancelTasksRequest cancelTasksRequest, RequestOptions options, ActionListener listener) {
+ restHighLevelClient.performRequestAsyncAndParseEntity(
+ cancelTasksRequest,
+ RequestConverters::cancelTasks,
+ options,
+ parser -> CancelTasksResponse.fromXContent(parser),
+ 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 9782b1016b4..d41c47177f9 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.XContentType;
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 class BulkProcessorIT extends ESRestHighLevelClientTestCase {
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 class BulkProcessorIT extends ESRestHighLevelClientTestCase {
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 class BulkProcessorIT extends ESRestHighLevelClientTestCase {
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 class BulkProcessorIT extends ESRestHighLevelClientTestCase {
}
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 class BulkProcessorIT extends ESRestHighLevelClientTestCase {
}
}
- 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 597d35a9996..fe6aa6b1017 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 class BulkProcessorRetryIT extends ESRestHighLevelClientTestCase {
}
}
- 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 9314bb2e36c..f1110163b25 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 class ClusterClientIT extends ESRestHighLevelClientTestCase {
setRequest.persistentSettings(map);
ClusterUpdateSettingsResponse setResponse = execute(setRequest, highLevelClient().cluster()::putSettings,
+ highLevelClient().cluster()::putSettingsAsync, highLevelClient().cluster()::putSettings,
highLevelClient().cluster()::putSettingsAsync);
assertAcked(setResponse);
@@ -79,6 +80,7 @@ public class ClusterClientIT extends ESRestHighLevelClientTestCase {
resetRequest.persistentSettings("{\"" + persistentSettingKey + "\": null }", XContentType.JSON);
ClusterUpdateSettingsResponse resetResponse = execute(resetRequest, highLevelClient().cluster()::putSettings,
+ highLevelClient().cluster()::putSettingsAsync, highLevelClient().cluster()::putSettings,
highLevelClient().cluster()::putSettingsAsync);
assertThat(resetResponse.getTransientSettings().get(transientSettingKey), equalTo(null));
@@ -100,6 +102,7 @@ public class ClusterClientIT extends ESRestHighLevelClientTestCase {
clusterUpdateSettingsRequest.transientSettings(Settings.builder().put(setting, value).build());
ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> execute(clusterUpdateSettingsRequest,
+ highLevelClient().cluster()::putSettings, highLevelClient().cluster()::putSettingsAsync,
highLevelClient().cluster()::putSettings, highLevelClient().cluster()::putSettingsAsync));
assertThat(exception.status(), equalTo(RestStatus.BAD_REQUEST));
assertThat(exception.getMessage(), equalTo(
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java
index f384e5706b0..81c894f242f 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 class CrudIT extends ESRestHighLevelClientTestCase {
{
// 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 class CrudIT extends ESRestHighLevelClientTestCase {
// Testing non existing document
String docId = "does_not_exist";
DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId);
- DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync);
+ 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 class CrudIT extends ESRestHighLevelClientTestCase {
{
// 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 class CrudIT extends ESRestHighLevelClientTestCase {
{
// Testing version type
String docId = "version_type";
- highLevelClient().index(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar"))
- .versionType(VersionType.EXTERNAL).version(12));
+ highLevelClient().index(
+ 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);
+ 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 class CrudIT extends ESRestHighLevelClientTestCase {
{
// Testing version type with a wrong version
String docId = "wrong_version";
- highLevelClient().index(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar"))
- .versionType(VersionType.EXTERNAL).version(12));
+ highLevelClient().index(
+ 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);
+ 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 class CrudIT extends ESRestHighLevelClientTestCase {
{
// 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 class CrudIT extends ESRestHighLevelClientTestCase {
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 class CrudIT extends ESRestHighLevelClientTestCase {
{
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 class CrudIT extends ESRestHighLevelClientTestCase {
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 class CrudIT extends ESRestHighLevelClientTestCase {
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 class CrudIT extends ESRestHighLevelClientTestCase {
}
{
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 class CrudIT extends ESRestHighLevelClientTestCase {
{
GetRequest getRequest = new GetRequest("index", "type", "id");
getRequest.fetchSourceContext(new FetchSourceContext(false, Strings.EMPTY_ARRAY, Strings.EMPTY_ARRAY));
- GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync);
+ 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 class CrudIT extends ESRestHighLevelClientTestCase {
} 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 class CrudIT extends ESRestHighLevelClientTestCase {
MultiGetRequest multiGetRequest = new MultiGetRequest();
multiGetRequest.add("index", "type", "id1");
multiGetRequest.add("index", "type", "id2");
- MultiGetResponse response = execute(multiGetRequest, highLevelClient()::multiGet, highLevelClient()::multiGetAsync);
+ 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 class CrudIT extends ESRestHighLevelClientTestCase {
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 class CrudIT extends ESRestHighLevelClientTestCase {
IndexRequest indexRequest = new IndexRequest("index", "type");
indexRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("test", "test").endObject());
- IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync);
+ 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 class CrudIT extends ESRestHighLevelClientTestCase {
IndexRequest indexRequest = new IndexRequest("index", "type", "id");
indexRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("version", 1).endObject());
- IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync);
+ 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 class CrudIT extends ESRestHighLevelClientTestCase {
indexRequest = new IndexRequest("index", "type", "id");
indexRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("version", 2).endObject());
- indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync);
+ 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 class CrudIT extends ESRestHighLevelClientTestCase {
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 class CrudIT extends ESRestHighLevelClientTestCase {
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 class CrudIT extends ESRestHighLevelClientTestCase {
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 class CrudIT extends ESRestHighLevelClientTestCase {
indexRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("field", "test").endObject());
indexRequest.opType(DocWriteRequest.OpType.CREATE);
- IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync);
+ 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 class CrudIT extends ESRestHighLevelClientTestCase {
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 class CrudIT extends ESRestHighLevelClientTestCase {
{
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 class CrudIT extends ESRestHighLevelClientTestCase {
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 class CrudIT extends ESRestHighLevelClientTestCase {
{
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 class CrudIT extends ESRestHighLevelClientTestCase {
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 class CrudIT extends ESRestHighLevelClientTestCase {
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 class CrudIT extends ESRestHighLevelClientTestCase {
updateRequest.doc(singletonMap("field_2", "two"), randomFrom(XContentType.values()));
updateRequest.fetchSource("field_*", "field_3");
- UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync);
+ 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 class CrudIT extends ESRestHighLevelClientTestCase {
{
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 class CrudIT extends ESRestHighLevelClientTestCase {
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 class CrudIT extends ESRestHighLevelClientTestCase {
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 class CrudIT extends ESRestHighLevelClientTestCase {
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 class CrudIT extends ESRestHighLevelClientTestCase {
UpdateRequest updateRequest = new UpdateRequest("index", "type", "id");
updateRequest.doc(new IndexRequest().source(Collections.singletonMap("field", "doc"), XContentType.JSON));
updateRequest.upsert(new IndexRequest().source(Collections.singletonMap("field", "upsert"), XContentType.YAML));
- execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync);
+ 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 class CrudIT extends ESRestHighLevelClientTestCase {
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 class CrudIT extends ESRestHighLevelClientTestCase {
} 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 class CrudIT extends ESRestHighLevelClientTestCase {
.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 class CrudIT extends ESRestHighLevelClientTestCase {
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 class CrudIT extends ESRestHighLevelClientTestCase {
} 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 class CrudIT extends ESRestHighLevelClientTestCase {
.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 class CrudIT extends ESRestHighLevelClientTestCase {
{
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 class CrudIT extends ESRestHighLevelClientTestCase {
{
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 class CrudIT extends ESRestHighLevelClientTestCase {
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 f7a934405c2..14fe0e01d31 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 @@ public abstract class ESRestHighLevelClientTestCase extends ESRestTestCase {
* 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 55357e06ab2..986c3380ff3 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
@@ -110,6 +110,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
boolean response = execute(
request,
highLevelClient().indices()::exists,
+ highLevelClient().indices()::existsAsync,
+ highLevelClient().indices()::exists,
highLevelClient().indices()::existsAsync
);
assertTrue(response);
@@ -125,6 +127,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
boolean response = execute(
request,
highLevelClient().indices()::exists,
+ highLevelClient().indices()::existsAsync,
+ highLevelClient().indices()::exists,
highLevelClient().indices()::existsAsync
);
assertFalse(response);
@@ -143,6 +147,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
boolean response = execute(
request,
highLevelClient().indices()::exists,
+ highLevelClient().indices()::existsAsync,
+ highLevelClient().indices()::exists,
highLevelClient().indices()::existsAsync
);
assertFalse(response);
@@ -160,7 +166,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
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));
@@ -188,7 +195,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
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);
@@ -323,7 +331,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
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);
@@ -375,7 +384,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
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));
@@ -388,7 +398,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
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());
}
}
@@ -407,6 +418,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
addAction.routing("routing").searchRouting("search_routing").filter("{\"term\":{\"year\":2016}}");
aliasesAddRequest.addAliasAction(addAction);
IndicesAliasesResponse aliasesAddResponse = execute(aliasesAddRequest, highLevelClient().indices()::updateAliases,
+ highLevelClient().indices()::updateAliasesAsync, highLevelClient().indices()::updateAliases,
highLevelClient().indices()::updateAliasesAsync);
assertTrue(aliasesAddResponse.isAcknowledged());
assertThat(aliasExists(alias), equalTo(true));
@@ -425,6 +437,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
AliasActions removeAction = new AliasActions(AliasActions.Type.REMOVE).index(index).alias(alias);
aliasesAddRemoveRequest.addAliasAction(removeAction);
IndicesAliasesResponse aliasesAddRemoveResponse = execute(aliasesAddRemoveRequest, highLevelClient().indices()::updateAliases,
+ highLevelClient().indices()::updateAliasesAsync, highLevelClient().indices()::updateAliases,
highLevelClient().indices()::updateAliasesAsync);
assertTrue(aliasesAddRemoveResponse.isAcknowledged());
assertThat(aliasExists(alias), equalTo(false));
@@ -436,6 +449,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
AliasActions removeIndexAction = new AliasActions(AliasActions.Type.REMOVE_INDEX).index(index);
aliasesRemoveIndexRequest.addAliasAction(removeIndexAction);
IndicesAliasesResponse aliasesRemoveIndexResponse = execute(aliasesRemoveIndexRequest, highLevelClient().indices()::updateAliases,
+ highLevelClient().indices()::updateAliasesAsync, highLevelClient().indices()::updateAliases,
highLevelClient().indices()::updateAliasesAsync);
assertTrue(aliasesRemoveIndexResponse.isAcknowledged());
assertThat(aliasExists(alias), equalTo(false));
@@ -453,7 +467,9 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
IndicesAliasesRequest nonExistentIndexRequest = new IndicesAliasesRequest();
nonExistentIndexRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index(nonExistentIndex).alias(alias));
ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> execute(nonExistentIndexRequest,
- highLevelClient().indices()::updateAliases, highLevelClient().indices()::updateAliasesAsync));
+ highLevelClient().indices()::updateAliases, highLevelClient().indices()::updateAliasesAsync,
+ highLevelClient().indices()::updateAliases,
+ highLevelClient().indices()::updateAliasesAsync));
assertThat(exception.status(), equalTo(RestStatus.NOT_FOUND));
assertThat(exception.getMessage(), equalTo("Elasticsearch exception [type=index_not_found_exception, reason=no such index]"));
assertThat(exception.getMetadata("es.index"), hasItem(nonExistentIndex));
@@ -463,7 +479,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
mixedRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).indices(index).aliases(alias));
mixedRequest.addAliasAction(new AliasActions(AliasActions.Type.REMOVE).indices(nonExistentIndex).alias(alias));
exception = expectThrows(ElasticsearchStatusException.class,
- () -> execute(mixedRequest, highLevelClient().indices()::updateAliases, highLevelClient().indices()::updateAliasesAsync));
+ () -> 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));
@@ -475,6 +492,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
removeIndexRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index(nonExistentIndex).alias(alias));
removeIndexRequest.addAliasAction(new AliasActions(AliasActions.Type.REMOVE_INDEX).indices(nonExistentIndex));
exception = expectThrows(ElasticsearchException.class, () -> execute(removeIndexRequest, highLevelClient().indices()::updateAliases,
+ highLevelClient().indices()::updateAliasesAsync, highLevelClient().indices()::updateAliases,
highLevelClient().indices()::updateAliasesAsync));
assertThat(exception.status(), equalTo(RestStatus.NOT_FOUND));
assertThat(exception.getMessage(), equalTo("Elasticsearch exception [type=index_not_found_exception, reason=no such index]"));
@@ -495,6 +513,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
OpenIndexRequest openIndexRequest = new OpenIndexRequest(index);
OpenIndexResponse openIndexResponse = execute(openIndexRequest, highLevelClient().indices()::open,
+ highLevelClient().indices()::openAsync, highLevelClient().indices()::open,
highLevelClient().indices()::openAsync);
assertTrue(openIndexResponse.isAcknowledged());
@@ -508,19 +527,22 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
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());
}
@@ -532,6 +554,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
CloseIndexRequest closeIndexRequest = new CloseIndexRequest(index);
CloseIndexResponse closeIndexResponse = execute(closeIndexRequest, highLevelClient().indices()::close,
+ highLevelClient().indices()::closeAsync, highLevelClient().indices()::close,
highLevelClient().indices()::closeAsync);
assertTrue(closeIndexResponse.isAcknowledged());
@@ -547,7 +570,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
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());
}
@@ -561,7 +585,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
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));
@@ -572,7 +597,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
assertFalse(indexExists(nonExistentIndex));
RefreshRequest refreshRequest = new RefreshRequest(nonExistentIndex);
ElasticsearchException exception = expectThrows(ElasticsearchException.class,
- () -> execute(refreshRequest, highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync));
+ () -> execute(refreshRequest, highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync,
+ highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync));
assertEquals(RestStatus.NOT_FOUND, exception.status());
}
}
@@ -587,7 +613,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
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));
@@ -598,7 +625,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
assertFalse(indexExists(nonExistentIndex));
FlushRequest flushRequest = new FlushRequest(nonExistentIndex);
ElasticsearchException exception = expectThrows(ElasticsearchException.class,
- () -> execute(flushRequest, highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync));
+ () -> execute(flushRequest, highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync,
+ highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync));
assertEquals(RestStatus.NOT_FOUND, exception.status());
}
}
@@ -646,7 +674,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
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));
@@ -657,8 +686,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
assertFalse(indexExists(nonExistentIndex));
ClearIndicesCacheRequest clearCacheRequest = new ClearIndicesCacheRequest(nonExistentIndex);
ElasticsearchException exception = expectThrows(ElasticsearchException.class,
- () -> execute(clearCacheRequest, highLevelClient().indices()::clearCache,
- highLevelClient().indices()::clearCacheAsync));
+ () -> execute(clearCacheRequest, highLevelClient().indices()::clearCache, highLevelClient().indices()::clearCacheAsync,
+ highLevelClient().indices()::clearCache, highLevelClient().indices()::clearCacheAsync));
assertEquals(RestStatus.NOT_FOUND, exception.status());
}
}
@@ -673,7 +702,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
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));
@@ -684,25 +714,30 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
assertFalse(indexExists(nonExistentIndex));
ForceMergeRequest forceMergeRequest = new ForceMergeRequest(nonExistentIndex);
ElasticsearchException exception = expectThrows(ElasticsearchException.class,
- () -> execute(forceMergeRequest, highLevelClient().indices()::forceMerge, highLevelClient().indices()::forceMergeAsync));
+ () -> 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")
@@ -722,7 +757,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
.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");
@@ -744,7 +780,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
resizeRequest.setResizeType(ResizeType.SPLIT);
Settings targetSettings = Settings.builder().put("index.number_of_shards", 4).put("index.number_of_replicas", 0).build();
resizeRequest.setTargetIndex(new CreateIndexRequest("target").settings(targetSettings).alias(new Alias("alias")));
- ResizeResponse resizeResponse = 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");
@@ -757,12 +794,13 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
}
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());
@@ -773,15 +811,16 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
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());
@@ -796,6 +835,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
rolloverRequest.dryRun(false);
rolloverRequest.addMaxIndexSizeCondition(new ByteSizeValue(1, ByteSizeUnit.MB));
RolloverResponse rolloverResponse = execute(rolloverRequest, highLevelClient().indices()::rollover,
+ highLevelClient().indices()::rolloverAsync, highLevelClient().indices()::rollover,
highLevelClient().indices()::rolloverAsync);
assertTrue(rolloverResponse.isRolledOver());
assertFalse(rolloverResponse.isDryRun());
@@ -830,6 +870,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
UpdateSettingsRequest dynamicSettingRequest = new UpdateSettingsRequest();
dynamicSettingRequest.settings(Settings.builder().put(dynamicSettingKey, dynamicSettingValue).build());
UpdateSettingsResponse response = execute(dynamicSettingRequest, highLevelClient().indices()::putSettings,
+ highLevelClient().indices()::putSettingsAsync, highLevelClient().indices()::putSettings,
highLevelClient().indices()::putSettingsAsync);
assertTrue(response.isAcknowledged());
@@ -840,6 +881,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
UpdateSettingsRequest staticSettingRequest = new UpdateSettingsRequest();
staticSettingRequest.settings(Settings.builder().put(staticSettingKey, staticSettingValue).build());
ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> execute(staticSettingRequest,
+ highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync,
highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync));
assertThat(exception.getMessage(),
startsWith("Elasticsearch exception [type=illegal_argument_exception, "
@@ -850,6 +892,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
closeIndex(index);
response = execute(staticSettingRequest, highLevelClient().indices()::putSettings,
+ highLevelClient().indices()::putSettingsAsync, highLevelClient().indices()::putSettings,
highLevelClient().indices()::putSettingsAsync);
assertTrue(response.isAcknowledged());
openIndex(index);
@@ -860,6 +903,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
UpdateSettingsRequest unmodifiableSettingRequest = new UpdateSettingsRequest();
unmodifiableSettingRequest.settings(Settings.builder().put(unmodifiableSettingKey, unmodifiableSettingValue).build());
exception = expectThrows(ElasticsearchException.class, () -> execute(unmodifiableSettingRequest,
+ highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync,
highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync));
assertThat(exception.getMessage(), startsWith(
"Elasticsearch exception [type=illegal_argument_exception, "
@@ -887,12 +931,14 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
indexUpdateSettingsRequest.settings(Settings.builder().put(setting, value).build());
ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> execute(indexUpdateSettingsRequest,
+ highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync,
highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync));
assertEquals(RestStatus.NOT_FOUND, exception.status());
assertThat(exception.getMessage(), equalTo("Elasticsearch exception [type=index_not_found_exception, reason=no such index]"));
createIndex(index, Settings.EMPTY);
exception = expectThrows(ElasticsearchException.class, () -> execute(indexUpdateSettingsRequest,
+ highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync,
highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync));
assertThat(exception.status(), equalTo(RestStatus.BAD_REQUEST));
assertThat(exception.getMessage(), equalTo(
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/PingAndInfoIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/PingAndInfoIT.java
index b4d8828eb7e..057ea49f9a9 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 @@ import java.util.Map;
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 9497bdded05..1e12f3f5e62 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 class RankEvalIT extends ESRestHighLevelClientTestCase {
RankEvalSpec spec = new RankEvalSpec(specifications, metric);
RankEvalRequest rankEvalRequest = new RankEvalRequest(spec, new String[] { "index", "index2" });
- RankEvalResponse response = execute(rankEvalRequest, highLevelClient()::rankEval,
- highLevelClient()::rankEvalAsync);
+ 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 class RankEvalIT extends ESRestHighLevelClientTestCase {
// now try this when test2 is closed
client().performRequest("POST", "index2/_close", Collections.emptyMap());
rankEvalRequest.indicesOptions(IndicesOptions.fromParameters(null, "true", null, SearchRequest.DEFAULT_INDICES_OPTIONS));
- response = execute(rankEvalRequest, highLevelClient()::rankEval, highLevelClient()::rankEvalAsync);
+ 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/RequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java
index ee372e255e7..a0312118a8b 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java
@@ -29,6 +29,8 @@ import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.util.EntityUtils;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.DocWriteRequest;
+import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest;
+import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksResponse;
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest;
import org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest;
import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesRequest;
@@ -1587,6 +1589,23 @@ public class RequestConvertersTests extends ESTestCase {
assertEquals(expectedParams, request.getParameters());
}
+ public void testCancelTasks() {
+ CancelTasksRequest request = new CancelTasksRequest();
+ Map expectedParams = new HashMap<>();
+ TaskId taskId = new TaskId(randomAlphaOfLength(5), randomNonNegativeLong());
+ TaskId parentTaskId = new TaskId(randomAlphaOfLength(5), randomNonNegativeLong());
+ request.setTaskId(taskId);
+ request.setParentTaskId(parentTaskId);
+ expectedParams.put("task_id", taskId.toString());
+ expectedParams.put("parent_task_id", parentTaskId.toString());
+ Request httpRequest = RequestConverters.cancelTasks(request);
+ assertThat(httpRequest, notNullValue());
+ assertThat(httpRequest.getMethod(), equalTo(HttpPost.METHOD_NAME));
+ assertThat(httpRequest.getEntity(), nullValue());
+ assertThat(httpRequest.getEndpoint(), equalTo("/_tasks/_cancel"));
+ assertThat(httpRequest.getParameters(), equalTo(expectedParams));
+ }
+
public void testListTasks() {
{
ListTasksRequest request = new ListTasksRequest();
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 5ca9b05f73a..9084a547c16 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.HttpResponse;
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.search.suggest.Suggest;
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 class RestHighLevelClientTests extends ESTestCase {
}
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 class RestHighLevelClientTests extends ESTestCase {
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 class RestHighLevelClientTests extends ESTestCase {
}
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 e147642fc73..80d09acf281 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 class SearchIT extends ESRestHighLevelClientTestCase {
public void testSearchMatchQuery() throws IOException {
SearchRequest searchRequest = new SearchRequest("index");
searchRequest.source(new SearchSourceBuilder().query(new MatchQueryBuilder("num", 10)));
- SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
+ 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 class SearchIT extends ESRestHighLevelClientTestCase {
searchSourceBuilder.aggregation(new TermsAggregationBuilder("agg1", ValueType.STRING).field("type.keyword"));
searchSourceBuilder.size(0);
searchRequest.source(searchSourceBuilder);
- SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
+ 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 class SearchIT extends ESRestHighLevelClientTestCase {
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 class SearchIT extends ESRestHighLevelClientTestCase {
.addRange("first", 0, 30).addRange("second", 31, 200));
searchSourceBuilder.size(0);
searchRequest.source(searchSourceBuilder);
- SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
+ 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 class SearchIT extends ESRestHighLevelClientTestCase {
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 class SearchIT extends ESRestHighLevelClientTestCase {
searchSourceBuilder.aggregation(new MatrixStatsAggregationBuilder("agg1").fields(Arrays.asList("num", "num2")));
searchSourceBuilder.size(0);
searchRequest.source(searchSourceBuilder);
- SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
+ 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 class SearchIT extends ESRestHighLevelClientTestCase {
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 class SearchIT extends ESRestHighLevelClientTestCase {
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 class SearchIT extends ESRestHighLevelClientTestCase {
{
SearchRequest searchRequest = new SearchRequest("test").source(SearchSourceBuilder.searchSource()
.scriptField("result", new Script("null")));
- SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
+ 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 class SearchIT extends ESRestHighLevelClientTestCase {
{
SearchRequest searchRequest = new SearchRequest("test").source(SearchSourceBuilder.searchSource()
.scriptField("result", new Script("new HashMap()")));
- SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
+ 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 class SearchIT extends ESRestHighLevelClientTestCase {
{
SearchRequest searchRequest = new SearchRequest("test").source(SearchSourceBuilder.searchSource()
.scriptField("result", new Script("new String[]{}")));
- SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
+ 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 class SearchIT extends ESRestHighLevelClientTestCase {
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(35).sort("field", SortOrder.ASC);
SearchRequest searchRequest = new SearchRequest("test").scroll(TimeValue.timeValueMinutes(2)).source(searchSourceBuilder);
- SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
+ SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync,
+ highLevelClient()::search, highLevelClient()::searchAsync);
try {
long counter = 0;
@@ -525,6 +537,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
}
searchResponse = execute(new SearchScrollRequest(searchResponse.getScrollId()).scroll(TimeValue.timeValueMinutes(2)),
+ highLevelClient()::searchScroll, highLevelClient()::searchScrollAsync,
highLevelClient()::searchScroll, highLevelClient()::searchScrollAsync);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(100L));
@@ -534,6 +547,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
}
searchResponse = execute(new SearchScrollRequest(searchResponse.getScrollId()).scroll(TimeValue.timeValueMinutes(2)),
+ highLevelClient()::searchScroll, highLevelClient()::searchScrollAsync,
highLevelClient()::searchScroll, highLevelClient()::searchScrollAsync);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(100L));
@@ -545,14 +559,14 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
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 class SearchIT extends ESRestHighLevelClientTestCase {
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 class SearchIT extends ESRestHighLevelClientTestCase {
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 class SearchIT extends ESRestHighLevelClientTestCase {
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 class SearchIT extends ESRestHighLevelClientTestCase {
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/TasksIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/TasksIT.java
index fc7d70a36e1..baa97cfa5b4 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/TasksIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/TasksIT.java
@@ -19,9 +19,12 @@
package org.elasticsearch.client;
+import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest;
+import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksResponse;
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest;
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse;
import org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup;
+import org.elasticsearch.tasks.TaskId;
import org.elasticsearch.tasks.TaskInfo;
import java.io.IOException;
@@ -58,4 +61,26 @@ public class TasksIT extends ESRestHighLevelClientTestCase {
assertTrue("List tasks were not found", listTasksFound);
}
+ public void testCancelTasks() throws IOException {
+ ListTasksRequest listRequest = new ListTasksRequest();
+ ListTasksResponse listResponse = execute(
+ listRequest,
+ highLevelClient().tasks()::list,
+ highLevelClient().tasks()::listAsync
+ );
+ // in this case, probably no task will actually be cancelled.
+ // this is ok, that case is covered in TasksIT.testTasksCancellation
+ TaskInfo firstTask = listResponse.getTasks().get(0);
+ String node = listResponse.getPerNodeTasks().keySet().iterator().next();
+
+ CancelTasksRequest cancelTasksRequest = new CancelTasksRequest();
+ cancelTasksRequest.setTaskId(new TaskId(node, firstTask.getId()));
+ cancelTasksRequest.setReason("testreason");
+ CancelTasksResponse response = execute(cancelTasksRequest,
+ highLevelClient().tasks()::cancel,
+ highLevelClient().tasks()::cancelAsync);
+ // Since the task may or may not have been cancelled, assert that we received a response only
+ // The actual testing of task cancellation is covered by TasksIT.testTasksCancellation
+ assertThat(response, notNullValue());
+ }
}
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 6641aa2fc7d..ef92e28a072 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.UpdateRequest;
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.Map;
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
"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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
//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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
.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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
.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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
"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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
.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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
//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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
.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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
//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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
{
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
// 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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
{
// 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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
}
{
- 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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
// 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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
.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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
.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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
//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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
//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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
//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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
// 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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
// 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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
// 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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
// 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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
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 304c5010a47..75902cf02ba 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.ActionListener;
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 class ClusterClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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 class ClusterClientDocumentationIT extends ESRestHighLevelClientTestCase
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,10 +172,11 @@ public class ClusterClientDocumentationIT extends ESRestHighLevelClientTestCase
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 c3decd93a17..2b81e4a4adc 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
@@ -64,6 +64,7 @@ import org.elasticsearch.action.support.ActiveShardCount;
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.cluster.metadata.MappingMetaData;
@@ -111,7 +112,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
RestHighLevelClient client = highLevelClient();
{
- CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"));
+ CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"), RequestOptions.DEFAULT);
assertTrue(createIndexResponse.isAcknowledged());
}
@@ -130,7 +131,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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);
}
@@ -140,7 +141,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
RestHighLevelClient client = highLevelClient();
{
- CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"));
+ CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"), RequestOptions.DEFAULT);
assertTrue(createIndexResponse.isAcknowledged());
}
@@ -167,7 +168,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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));
@@ -177,7 +178,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
RestHighLevelClient client = highLevelClient();
{
- CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("posts"));
+ CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("posts"), RequestOptions.DEFAULT);
assertTrue(createIndexResponse.isAcknowledged());
}
@@ -199,7 +200,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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
@@ -212,7 +213,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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>
@@ -226,7 +227,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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());
}
@@ -253,7 +254,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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));
@@ -289,7 +290,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
"}", // <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());
}
@@ -306,7 +307,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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());
}
{
@@ -332,7 +333,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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());
}
{
@@ -340,7 +341,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
//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());
}
@@ -362,7 +363,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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());
}
@@ -387,7 +388,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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
@@ -426,7 +427,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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));
@@ -437,7 +438,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
RestHighLevelClient client = highLevelClient();
{
- CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"));
+ CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"), RequestOptions.DEFAULT);
assertTrue(createIndexResponse.isAcknowledged());
}
@@ -459,7 +460,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
"}", // <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());
}
@@ -473,7 +474,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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());
}
{
@@ -494,14 +495,14 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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());
}
@@ -515,7 +516,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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
@@ -529,7 +530,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
final RestHighLevelClient client = highLevelClient();
{
- CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"));
+ CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"), RequestOptions.DEFAULT);
assertTrue(createIndexResponse.isAcknowledged());
}
@@ -556,7 +557,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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));
@@ -601,7 +602,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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
@@ -683,7 +684,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
});
// 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));
@@ -694,7 +695,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
RestHighLevelClient client = highLevelClient();
{
- CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index"));
+ CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index"), RequestOptions.DEFAULT);
assertTrue(createIndexResponse.isAcknowledged());
}
@@ -721,7 +722,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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
@@ -751,7 +752,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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));
@@ -761,7 +762,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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>
@@ -790,7 +791,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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
@@ -819,7 +820,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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));
@@ -829,7 +830,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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>
@@ -866,7 +867,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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
@@ -895,7 +896,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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));
@@ -905,7 +906,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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>
@@ -934,7 +935,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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
@@ -978,7 +979,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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));
@@ -988,7 +989,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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>
@@ -1003,7 +1004,8 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
{
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());
}
@@ -1020,7 +1022,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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
@@ -1055,7 +1057,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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));
@@ -1066,7 +1068,8 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
{
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());
}
@@ -1077,7 +1080,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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);
@@ -1107,7 +1110,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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));
}
@@ -1142,7 +1145,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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
@@ -1167,14 +1170,14 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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>
@@ -1219,7 +1222,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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
@@ -1248,7 +1251,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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));
@@ -1258,7 +1261,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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>
@@ -1272,7 +1275,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
RestHighLevelClient client = highLevelClient();
{
- CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index"));
+ CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index"), RequestOptions.DEFAULT);
assertTrue(createIndexResponse.isAcknowledged());
}
@@ -1295,7 +1298,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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
@@ -1323,7 +1326,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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));
@@ -1335,7 +1338,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
{
CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index")
- .alias(new Alias("alias")));
+ .alias(new Alias("alias")), RequestOptions.DEFAULT);
assertTrue(createIndexResponse.isAcknowledged());
}
@@ -1363,7 +1366,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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);
@@ -1386,7 +1389,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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));
@@ -1397,13 +1400,13 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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());
}
@@ -1448,7 +1451,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// tag::update-aliases-execute
IndicesAliasesResponse indicesAliasesResponse =
- client.indices().updateAliases(request);
+ client.indices().updateAliases(request, RequestOptions.DEFAULT);
// end::update-aliases-execute
// tag::update-aliases-response
@@ -1482,7 +1485,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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));
@@ -1527,7 +1530,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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
@@ -1556,7 +1559,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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));
@@ -1597,7 +1600,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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
@@ -1626,7 +1629,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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));
@@ -1636,7 +1639,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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
@@ -1673,7 +1676,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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
@@ -1712,7 +1715,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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));
@@ -1722,7 +1725,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
RestHighLevelClient client = highLevelClient();
{
- CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index"));
+ CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index"), RequestOptions.DEFAULT);
assertTrue(createIndexResponse.isAcknowledged());
}
@@ -1785,7 +1788,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
// tag::put-settings-execute
UpdateSettingsResponse updateSettingsResponse =
- client.indices().putSettings(request);
+ client.indices().putSettings(request, RequestOptions.DEFAULT);
// end::put-settings-execute
// tag::put-settings-response
@@ -1814,7 +1817,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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));
@@ -1849,7 +1852,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
"}", // <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
@@ -1863,7 +1866,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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
@@ -1887,13 +1890,13 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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
@@ -1947,7 +1950,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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
@@ -1975,7 +1978,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
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 7971e49da44..f5bdc9f2f3e 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.GetPipelineResponse;
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 class IngestClientDocumentationIT extends ESRestHighLevelClientTestCase {
// 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 class IngestClientDocumentationIT extends ESRestHighLevelClientTestCase {
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 class IngestClientDocumentationIT extends ESRestHighLevelClientTestCase {
// 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 class IngestClientDocumentationIT extends ESRestHighLevelClientTestCase {
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 class IngestClientDocumentationIT extends ESRestHighLevelClientTestCase {
// 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 class IngestClientDocumentationIT extends ESRestHighLevelClientTestCase {
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 489d4d9b1ed..b56fb3359ff 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.IndexRequest;
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.IOException;
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 class MigrationDocumentationIT extends ESRestHighLevelClientTestCase {
//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 class MigrationDocumentationIT extends ESRestHighLevelClientTestCase {
}
});
//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 504ea797c35..2186bd8ebfd 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.Build;
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 class MiscellaneousDocumentationIT extends ESRestHighLevelClientTestCase
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 class MiscellaneousDocumentationIT extends ESRestHighLevelClientTestCase
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 463c5f7d12f..cf6409bab64 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.IndicesOptions;
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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
// 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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
// 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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
// 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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
.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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
.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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
// 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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
// 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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
// 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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
// 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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
// 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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
// 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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
// 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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
// 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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
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 class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
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 @@ public class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
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 2890ad50c26..8c158a91a51 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.put.PutRepositoryResp
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 class SnapshotClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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 class SnapshotClientDocumentationIT extends ESRestHighLevelClientTestCase
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 class SnapshotClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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 class SnapshotClientDocumentationIT extends ESRestHighLevelClientTestCase
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 class SnapshotClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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 class SnapshotClientDocumentationIT extends ESRestHighLevelClientTestCase
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 class SnapshotClientDocumentationIT extends ESRestHighLevelClientTestCase
// 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 class SnapshotClientDocumentationIT extends ESRestHighLevelClientTestCase
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 @@ public class SnapshotClientDocumentationIT extends ESRestHighLevelClientTestCase
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 faf447a4143..8a45195757c 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
@@ -23,10 +23,13 @@ import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.LatchedActionListener;
import org.elasticsearch.action.TaskOperationFailure;
+import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest;
+import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksResponse;
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest;
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 +93,7 @@ public class TasksClientDocumentationIT extends ESRestHighLevelClientTestCase {
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,10 +142,80 @@ public class TasksClientDocumentationIT extends ESRestHighLevelClientTestCase {
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));
}
}
+
+ public void testCancelTasks() throws IOException {
+ RestHighLevelClient client = highLevelClient();
+ {
+ // tag::cancel-tasks-request
+ CancelTasksRequest request = new CancelTasksRequest();
+ // end::cancel-tasks-request
+
+ // tag::cancel-tasks-request-filter
+ request.setTaskId(new TaskId("nodeId1", 42)); //<1>
+ request.setActions("cluster:*"); // <2>
+ request.setNodes("nodeId1", "nodeId2"); // <3>
+ // end::cancel-tasks-request-filter
+
+ }
+
+ CancelTasksRequest request = new CancelTasksRequest();
+ request.setTaskId(TaskId.EMPTY_TASK_ID);
+
+ // tag::cancel-tasks-execute
+ CancelTasksResponse response = client.tasks().cancel(request, RequestOptions.DEFAULT);
+ // end::cancel-tasks-execute
+
+ assertThat(response, notNullValue());
+
+ // tag::cancel-tasks-response-tasks
+ List tasks = response.getTasks(); // <1>
+ // end::cancel-tasks-response-tasks
+
+
+ // tag::cancel-tasks-response-failures
+ List nodeFailures = response.getNodeFailures(); // <1>
+ List taskFailures = response.getTaskFailures(); // <2>
+ // end::-tasks-response-failures
+
+ assertThat(response.getNodeFailures(), equalTo(emptyList()));
+ assertThat(response.getTaskFailures(), equalTo(emptyList()));
+ }
+
+ public void testAsyncCancelTasks() throws InterruptedException {
+
+ RestHighLevelClient client = highLevelClient();
+ {
+ CancelTasksRequest request = new CancelTasksRequest();
+
+ // tag::cancel-tasks-execute-listener
+ ActionListener listener =
+ new ActionListener() {
+ @Override
+ public void onResponse(CancelTasksResponse response) {
+ // <1>
+ }
+ @Override
+ public void onFailure(Exception e) {
+ // <2>
+ }
+ };
+ // end::cancel-tasks-execute-listener
+
+ // Replace the empty listener by a blocking listener in test
+ final CountDownLatch latch = new CountDownLatch(1);
+ listener = new LatchedActionListener<>(listener, latch);
+
+ // tag::cancel-tasks-execute-async
+ client.tasks().cancelAsync(request, RequestOptions.DEFAULT, listener); // <1>
+ // end::cancel-tasks-execute-async
+
+ assertTrue(latch.await(30L, TimeUnit.SECONDS));
+ }
+ }
}
diff --git a/client/rest/build.gradle b/client/rest/build.gradle
index bcb928495c5..b1ed05a8342 100644
--- a/client/rest/build.gradle
+++ b/client/rest/build.gradle
@@ -69,7 +69,7 @@ forbiddenApisTest {
}
// JarHell is part of es server, which we don't want to pull in
-// TODO: Not anymore. Now in elasticsearch-core
+// TODO: Not anymore. Now in :libs:core
jarHell.enabled=false
namingConventions {
diff --git a/client/sniffer/build.gradle b/client/sniffer/build.gradle
index e226656dbd2..41146e0b7ec 100644
--- a/client/sniffer/build.gradle
+++ b/client/sniffer/build.gradle
@@ -72,7 +72,7 @@ dependencyLicenses {
}
// JarHell is part of es server, which we don't want to pull in
-// TODO: Not anymore. Now in elasticsearch-core
+// TODO: Not anymore. Now in :libs:core
jarHell.enabled=false
namingConventions {
diff --git a/client/sniffer/src/test/java/org/elasticsearch/client/sniff/ElasticsearchHostsSnifferTests.java b/client/sniffer/src/test/java/org/elasticsearch/client/sniff/ElasticsearchHostsSnifferTests.java
index f13d1751104..ed2744df31c 100644
--- a/client/sniffer/src/test/java/org/elasticsearch/client/sniff/ElasticsearchHostsSnifferTests.java
+++ b/client/sniffer/src/test/java/org/elasticsearch/client/sniff/ElasticsearchHostsSnifferTests.java
@@ -30,7 +30,6 @@ import com.sun.net.httpserver.HttpServer;
import org.apache.http.Consts;
import org.apache.http.HttpHost;
import org.apache.http.client.methods.HttpGet;
-import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.client.RestClient;
@@ -148,8 +147,6 @@ public class ElasticsearchHostsSnifferTests extends RestClientTestCase {
return httpServer;
}
- //animal-sniffer doesn't like our usage of com.sun.net.httpserver.* classes
- @IgnoreJRERequirement
private static class ResponseHandler implements HttpHandler {
private final int sniffTimeoutMillis;
private final SniffResponse sniffResponse;
diff --git a/client/test/build.gradle b/client/test/build.gradle
index fd5777cc8df..59c45186fe7 100644
--- a/client/test/build.gradle
+++ b/client/test/build.gradle
@@ -21,7 +21,6 @@ import org.elasticsearch.gradle.precommit.PrecommitTasks
import org.gradle.api.JavaVersion
apply plugin: 'elasticsearch.build'
-apply plugin: 'ru.vyarus.animalsniffer'
targetCompatibility = JavaVersion.VERSION_1_7
sourceCompatibility = JavaVersion.VERSION_1_7
@@ -31,8 +30,6 @@ dependencies {
compile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
compile "junit:junit:${versions.junit}"
compile "org.hamcrest:hamcrest-all:${versions.hamcrest}"
- compile "org.codehaus.mojo:animal-sniffer-annotations:1.15"
- signature "org.codehaus.mojo.signature:java17:1.0@signature"
}
forbiddenApisMain {
@@ -49,7 +46,7 @@ forbiddenApisTest {
}
// JarHell is part of es server, which we don't want to pull in
-// TODO: Not anymore. Now in elasticsearch-core
+// TODO: Not anymore. Now in :libs:core
jarHell.enabled=false
// TODO: should we have licenses for our test deps?
diff --git a/distribution/src/bin/elasticsearch-cli b/distribution/src/bin/elasticsearch-cli
index c49c1a51619..5699b3feb58 100644
--- a/distribution/src/bin/elasticsearch-cli
+++ b/distribution/src/bin/elasticsearch-cli
@@ -24,5 +24,5 @@ exec \
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
-Des.distribution.type="$ES_DISTRIBUTION_TYPE" \
-cp "$ES_CLASSPATH" \
- $1 \
- "${@:2}"
+ "$ES_MAIN_CLASS" \
+ "$@"
diff --git a/distribution/src/bin/elasticsearch-cli.bat b/distribution/src/bin/elasticsearch-cli.bat
index e85abdee448..b668a7c06c2 100644
--- a/distribution/src/bin/elasticsearch-cli.bat
+++ b/distribution/src/bin/elasticsearch-cli.bat
@@ -6,11 +6,6 @@ if defined ES_ADDITIONAL_SOURCES (
)
)
-for /f "tokens=1*" %%a in ("%*") do (
- set main_class=%%a
- set arguments=%%b
-)
-
if defined ES_ADDITIONAL_CLASSPATH_DIRECTORIES (
for %%a in ("%ES_ADDITIONAL_CLASSPATH_DIRECTORIES:;=","%") do (
set ES_CLASSPATH=!ES_CLASSPATH!;!ES_HOME!/%%a/*
@@ -24,5 +19,5 @@ if defined ES_ADDITIONAL_CLASSPATH_DIRECTORIES (
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
-Des.distribution.type="%ES_DISTRIBUTION_TYPE%" ^
-cp "%ES_CLASSPATH%" ^
- %main_class% ^
- %arguments%
+ "%ES_MAIN_CLASS%" ^
+ %*
diff --git a/distribution/src/bin/elasticsearch-keystore b/distribution/src/bin/elasticsearch-keystore
index ebe24179a0e..49e1aa7437a 100755
--- a/distribution/src/bin/elasticsearch-keystore
+++ b/distribution/src/bin/elasticsearch-keystore
@@ -1,5 +1,5 @@
#!/bin/bash
-"`dirname "$0"`"/elasticsearch-cli \
- org.elasticsearch.common.settings.KeyStoreCli \
+ES_MAIN_CLASS=org.elasticsearch.common.settings.KeyStoreCli \
+ "`dirname "$0"`"/elasticsearch-cli \
"$@"
diff --git a/distribution/src/bin/elasticsearch-keystore.bat b/distribution/src/bin/elasticsearch-keystore.bat
index 380a3e501d5..b43182a273f 100644
--- a/distribution/src/bin/elasticsearch-keystore.bat
+++ b/distribution/src/bin/elasticsearch-keystore.bat
@@ -3,8 +3,8 @@
setlocal enabledelayedexpansion
setlocal enableextensions
+set ES_MAIN_CLASS=org.elasticsearch.common.settings.KeyStoreCli
call "%~dp0elasticsearch-cli.bat" ^
- org.elasticsearch.common.settings.KeyStoreCli ^
%%* ^
|| exit /b 1
diff --git a/distribution/src/bin/elasticsearch-plugin b/distribution/src/bin/elasticsearch-plugin
index adfb4a88ad2..1c11cfb35f2 100755
--- a/distribution/src/bin/elasticsearch-plugin
+++ b/distribution/src/bin/elasticsearch-plugin
@@ -1,6 +1,6 @@
#!/bin/bash
-ES_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/plugin-cli \
+ES_MAIN_CLASS=org.elasticsearch.plugins.PluginCli \
+ ES_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/plugin-cli \
"`dirname "$0"`"/elasticsearch-cli \
- org.elasticsearch.plugins.PluginCli \
"$@"
diff --git a/distribution/src/bin/elasticsearch-plugin.bat b/distribution/src/bin/elasticsearch-plugin.bat
index 5d7b1d7a828..7e71de790f0 100644
--- a/distribution/src/bin/elasticsearch-plugin.bat
+++ b/distribution/src/bin/elasticsearch-plugin.bat
@@ -3,9 +3,9 @@
setlocal enabledelayedexpansion
setlocal enableextensions
+set ES_MAIN_CLASS=org.elasticsearch.plugins.PluginCli
set ES_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/plugin-cli
call "%~dp0elasticsearch-cli.bat" ^
- org.elasticsearch.plugins.PluginCli ^
%%* ^
|| exit /b 1
diff --git a/distribution/src/bin/elasticsearch-translog b/distribution/src/bin/elasticsearch-translog
index 33350aaf0b6..aa5bfb32df1 100755
--- a/distribution/src/bin/elasticsearch-translog
+++ b/distribution/src/bin/elasticsearch-translog
@@ -1,5 +1,5 @@
#!/bin/bash
-"`dirname "$0"`"/elasticsearch-cli \
- org.elasticsearch.index.translog.TranslogToolCli \
+ES_MAIN_CLASS=org.elasticsearch.index.translog.TranslogToolCli \
+ "`dirname "$0"`"/elasticsearch-cli \
"$@"
diff --git a/distribution/src/bin/elasticsearch-translog.bat b/distribution/src/bin/elasticsearch-translog.bat
index 9c4cefcf2fe..6a2e3046205 100644
--- a/distribution/src/bin/elasticsearch-translog.bat
+++ b/distribution/src/bin/elasticsearch-translog.bat
@@ -3,8 +3,8 @@
setlocal enabledelayedexpansion
setlocal enableextensions
+set ES_MAIN_CLASS=org.elasticsearch.index.translog.TranslogToolCli
call "%~dp0elasticsearch-cli.bat" ^
- org.elasticsearch.index.translog.TranslogToolCli ^
%%* ^
|| exit /b 1
diff --git a/distribution/tools/launchers/build.gradle b/distribution/tools/launchers/build.gradle
index 27e8712ffcb..ff0f4c473a4 100644
--- a/distribution/tools/launchers/build.gradle
+++ b/distribution/tools/launchers/build.gradle
@@ -21,14 +21,11 @@ import org.elasticsearch.gradle.precommit.PrecommitTasks
import org.gradle.api.JavaVersion
apply plugin: 'elasticsearch.build'
-apply plugin: 'ru.vyarus.animalsniffer'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
- signature "org.codehaus.mojo.signature:java17:1.0@signature"
-
testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testCompile "junit:junit:${versions.junit}"
testCompile "org.hamcrest:hamcrest-all:${versions.hamcrest}"
diff --git a/docs/java-rest/high-level/supported-apis.asciidoc b/docs/java-rest/high-level/supported-apis.asciidoc
index 34149bee528..783cc773e96 100644
--- a/docs/java-rest/high-level/supported-apis.asciidoc
+++ b/docs/java-rest/high-level/supported-apis.asciidoc
@@ -140,5 +140,7 @@ include::snapshot/verify_repository.asciidoc[]
The Java High Level REST Client supports the following Tasks APIs:
* <>
+* <>
include::tasks/list_tasks.asciidoc[]
+include::tasks/cancel_tasks.asciidoc[]
diff --git a/docs/java-rest/high-level/tasks/cancel_tasks.asciidoc b/docs/java-rest/high-level/tasks/cancel_tasks.asciidoc
new file mode 100644
index 00000000000..089f87c00a2
--- /dev/null
+++ b/docs/java-rest/high-level/tasks/cancel_tasks.asciidoc
@@ -0,0 +1,82 @@
+[[java-rest-high-cluster-cancel-tasks]]
+=== Cancel Tasks API
+
+The Cancel Tasks API allows cancellation of a currently running task.
+
+==== Cancel Tasks Request
+
+A `CancelTasksRequest`:
+
+["source","java",subs="attributes,callouts,macros"]
+--------------------------------------------------
+include-tagged::{doc-tests}/TasksClientDocumentationIT.java[cancel-tasks-request]
+--------------------------------------------------
+There are no required parameters. The task cancellation command supports the same
+task selection parameters as the list tasks command.
+
+==== Parameters
+
+["source","java",subs="attributes,callouts,macros"]
+--------------------------------------------------
+include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-request-filter]
+--------------------------------------------------
+<1> Cancel a task
+<2> Cancel only cluster-related tasks
+<3> Cancel all tasks running on nodes nodeId1 and nodeId2
+
+==== Synchronous Execution
+
+["source","java",subs="attributes,callouts,macros"]
+--------------------------------------------------
+include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-execute]
+--------------------------------------------------
+
+==== Asynchronous Execution
+
+The asynchronous execution requires `CancelTasksRequest` instance and an
+`ActionListener` instance to be passed to the asynchronous method:
+
+["source","java",subs="attributes,callouts,macros"]
+--------------------------------------------------
+include-tagged::{doc-tests}/TasksClientDocumentationIT.java[cancel-tasks-execute-async]
+--------------------------------------------------
+<1> The `CancelTasksRequest` to execute and the `ActionListener` to use
+when the execution completes
+
+The asynchronous method does not block and returns immediately. Once it is
+completed the `ActionListener` is called back using the `onResponse` method
+if the execution successfully completed or using the `onFailure` method if
+it failed.
+
+A typical listener for `CancelTasksResponse` looks like:
+
+["source","java",subs="attributes,callouts,macros"]
+--------------------------------------------------
+include-tagged::{doc-tests}/TasksClientDocumentationIT.java[cancel-tasks-execute-listener]
+--------------------------------------------------
+<1> Called when the execution is successfully completed. The response is
+provided as an argument
+<2> Called in case of a failure. The raised exception is provided as an argument
+
+==== Cancel Tasks Response
+
+["source","java",subs="attributes,callouts,macros"]
+--------------------------------------------------
+include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-response-tasks]
+--------------------------------------------------
+<1> List of cancelled tasks
+
+["source","java",subs="attributes,callouts,macros"]
+--------------------------------------------------
+include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-response-calc]
+--------------------------------------------------
+<1> List of cancelled tasks grouped by a node
+<2> List of cancelled tasks grouped by a parent task
+
+["source","java",subs="attributes,callouts,macros"]
+--------------------------------------------------
+include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-response-failures]
+--------------------------------------------------
+<1> List of node failures
+<2> List of task cancellation failures
+
diff --git a/docs/painless/painless-casting.asciidoc b/docs/painless/painless-casting.asciidoc
index a3624f90831..4bcd14cbfc6 100644
--- a/docs/painless/painless-casting.asciidoc
+++ b/docs/painless/painless-casting.asciidoc
@@ -4,8 +4,11 @@
A cast converts the value of an original type to the equivalent value of a
target type. An implicit cast infers the target type and automatically occurs
during certain <>. An explicit cast specifies
-the target type and forcefully occurs as its own operation. Use the *cast
-operator* to specify an explicit cast.
+the target type and forcefully occurs as its own operation. Use the `cast
+operator '()'` to specify an explicit cast.
+
+Refer to the <> for a quick reference on all
+allowed casts.
*Errors*
@@ -13,6 +16,7 @@ operator* to specify an explicit cast.
* If an implicit cast is given, but an explicit cast is required.
*Grammar*
+
[source,ANTLR4]
----
cast: '(' TYPE ')' expression
@@ -31,15 +35,15 @@ cast: '(' TYPE ')' expression
+
<1> declare `int i`;
explicit cast `long 5` to `int 5` -> `int 5`;
- assign `int 5` to `i`
+ store `int 5` to `i`
<2> declare `Map m`;
allocate `HashMap` instance -> `HashMap reference`;
implicit cast `HashMap reference` to `Map reference` -> `Map reference`;
- assign `Map reference` to `m`
+ store `Map reference` to `m`
<3> declare `HashMap hm`;
- access `m` -> `Map reference`;
+ load from `m` -> `Map reference`;
explicit cast `Map reference` to `HashMap reference` -> `HashMap reference`;
- assign `HashMap reference` to `hm`
+ store `HashMap reference` to `hm`
[[numeric-type-casting]]
==== Numeric Type Casting
@@ -78,19 +82,19 @@ following table:
----
+
<1> declare `int a`;
- assign `int 1` to `a`
+ store `int 1` to `a`
<2> declare `long b`;
- access `a` -> `int 1`;
+ load from `a` -> `int 1`;
implicit cast `int 1` to `long 1` -> `long 1`;
- assign `long 1` to `b`
+ store `long 1` to `b`
<3> declare `short c`;
- access `b` -> `long 1`;
+ load from `b` -> `long 1`;
explicit cast `long 1` to `short 1` -> `short 1`;
- assign `short 1` value to `c`
+ store `short 1` value to `c`
<4> declare `double e`;
- access `a` -> `int 1`;
+ load from `a` -> `int 1`;
explicit cast `int 1` to `double 1.0`;
- assign `double 1.0` to `e`;
+ store `double 1.0` to `e`;
(note the explicit cast is extraneous since an implicit cast is valid)
+
* Invalid numeric type casts resulting in errors.
@@ -106,9 +110,9 @@ following table:
*error* -> cannot implicit cast `double 1.0` to `int 1`;
(note an explicit cast is valid)
<2> declare `int b`;
- assign `int 2` to `b`
+ store `int 2` to `b`
<3> declare byte `c`;
- access `b` -> `int 2`;
+ load from `b` -> `int 2`;
*error* -> cannot implicit cast `int 2` to `byte 2`;
(note an explicit cast is valid)
@@ -136,21 +140,21 @@ or the target type is a descendant of the original type.
----
+
<1> declare `List x`;
- assign default value `null` to `x`
+ store default value `null` to `x`
<2> declare `ArrayList y`;
allocate `ArrayList` instance -> `ArrayList reference`;
- assign `ArrayList reference` to `y`;
-<3> access `y` -> `ArrayList reference`;
+ store `ArrayList reference` to `y`;
+<3> load from `y` -> `ArrayList reference`;
implicit cast `ArrayList reference` to `List reference` -> `List reference`;
- assign `List reference` to `x`;
+ store `List reference` to `x`;
(note `ArrayList` is a descendant of `List`)
-<4> access `x` -> `List reference`;
+<4> load from `x` -> `List reference`;
explicit cast `List reference` to `ArrayList reference`
-> `ArrayList reference`;
- assign `ArrayList reference` to `y`;
-<5> access `y` -> `ArrayList reference`;
+ store `ArrayList reference` to `y`;
+<5> load from `y` -> `ArrayList reference`;
explicit cast `ArrayList reference` to `List reference` -> `List reference`;
- assign `List reference` to `x`;
+ store `List reference` to `x`;
(note the explicit cast is extraneous, and an implicit cast is valid)
+
* Invalid reference type casts resulting in errors.
@@ -165,16 +169,16 @@ or the target type is a descendant of the original type.
<1> declare `List x`;
allocate `ArrayList` instance -> `ArrayList reference`;
implicit cast `ArrayList reference` to `List reference` -> `List reference`;
- assign `List reference` to `x`
+ store `List reference` to `x`
<2> declare `ArrayList y`;
- access `x` -> `List reference`;
+ load from `x` -> `List reference`;
*error* -> cannot implicit cast `List reference` to `ArrayList reference`;
(note an explicit cast is valid since `ArrayList` is a descendant of `List`)
<3> declare `ArrayList y`;
- access `x` -> `List reference`;
+ load from `x` -> `List reference`;
*error* -> cannot explicit cast `List reference` to `Map reference`;
- (note no cast would be valid since neither `List` nor `Map` is a descendant
- of the other)
+ (note no cast is valid since neither `List` nor `Map` is a descendant of the
+ other)
[[dynamic-type-casting]]
==== Dynamic Type Casting
@@ -206,24 +210,24 @@ based on the current type value the `def` type value represents.
+
<1> declare `def d0`;
implicit cast `int 3` to `def`;
- assign `int 3` to `d0`
+ store `int 3` to `d0`
<2> allocate `ArrayList` instance -> `ArrayList reference`;
implicit cast `ArrayList reference` to `def` -> `def`;
- assign `def` to `d0`
+ store `def` to `d0`
<3> declare `Object o`;
allocate `HashMap` instance -> `HashMap reference`;
implicit cast `HashMap reference` to `Object reference`
-> `Object reference`;
- assign `Object reference` to `o`
+ store `Object reference` to `o`
<4> declare `def d1`;
- access `o` -> `Object reference`;
+ load from `o` -> `Object reference`;
implicit cast `Object reference` to `def` -> `def`;
- assign `def` to `d1`
+ store `def` to `d1`
<5> declare `int i`;
- access `d1` -> `def`;
+ load from `d1` -> `def`;
implicit cast `def` to `HashMap reference` -> HashMap reference`;
call `size` on `HashMap reference` -> `int 0`;
- assign `int 0` to `i`;
+ store `int 0` to `i`;
(note `def` was implicit cast to `HashMap reference` since `HashMap` is the
child-most descendant type value that the `def` type value
represents)
@@ -242,29 +246,29 @@ based on the current type value the `def` type value represents.
+
<1> declare `def d`;
implicit cast `double 1.0` to `def` -> `def`;
- assign `def` to `d`
+ store `def` to `d`
<2> declare `int i`;
- access `d` -> `def`;
+ load from `d` -> `def`;
implicit cast `def` to `double 1.0` -> `double 1.0`;
explicit cast `double 1.0` to `int 1` -> `int 1`;
- assign `int 1` to `i`;
- (note the explicit cast is necessary since a `double` value cannot be
- converted to an `int` value implicitly)
-<3> assign `int 1` to `d`;
+ store `int 1` to `i`;
+ (note the explicit cast is necessary since a `double` type value is not
+ converted to an `int` type value implicitly)
+<3> store `int 1` to `d`;
(note the switch in the type `d` represents from `double` to `int`)
<4> declare `float i`;
- access `d` -> `def`;
+ load from `d` -> `def`;
implicit cast `def` to `int 1` -> `int 1`;
implicit cast `int 1` to `float 1.0` -> `float 1.0`;
- assign `float 1.0` to `f`
+ store `float 1.0` to `f`
<5> allocate `ArrayList` instance -> `ArrayList reference`;
- assign `ArrayList reference` to `d`;
+ store `ArrayList reference` to `d`;
(note the switch in the type `d` represents from `int` to `ArrayList`)
<6> declare `List l`;
- access `d` -> `def`;
+ load from `d` -> `def`;
implicit cast `def` to `ArrayList reference` -> `ArrayList reference`;
implicit cast `ArrayList reference` to `List reference` -> `List reference`;
- assign `List reference` to `l`
+ store `List reference` to `l`
+
* Invalid dynamic type casts resulting in errors.
+
@@ -277,26 +281,26 @@ based on the current type value the `def` type value represents.
----
<1> declare `def d`;
implicit cast `int 1` to `def` -> `def`;
- assign `def` to `d`
+ store `def` to `d`
<2> declare `short s`;
- access `d` -> `def`;
+ load from `d` -> `def`;
implicit cast `def` to `int 1` -> `int 1`;
*error* -> cannot implicit cast `int 1` to `short 1`;
(note an explicit cast is valid)
<3> allocate `HashMap` instance -> `HashMap reference`;
implicit cast `HashMap reference` to `def` -> `def`;
- assign `def` to `d`
+ store `def` to `d`
<4> declare `List l`;
- access `d` -> `def`;
+ load from `d` -> `def`;
implicit cast `def` to `HashMap reference`;
*error* -> cannot implicit cast `HashMap reference` to `List reference`;
- (note no cast would be valid since neither `HashMap` nor `List` is a
- descendant of the other)
+ (note no cast is valid since neither `HashMap` nor `List` is a descendant of
+ the other)
[[string-character-casting]]
==== String to Character Casting
-Use the *cast operator* to convert a <> value into a
+Use the cast operator to convert a <> value into a
<> value.
*Errors*
@@ -310,17 +314,17 @@ Use the *cast operator* to convert a <> value into a
+
[source,Painless]
----
-<1> char c = (char)"C"
-<2> c = (char)'c'
+<1> char c = (char)"C";
+<2> c = (char)'c';
----
+
<1> declare `char c`;
explicit cast `String "C"` to `char C` -> `char C`;
- assign `char C` to `c`
+ store `char C` to `c`
<2> explicit cast `String 'c'` to `char c` -> `char c`;
- assign `char c` to `c`
+ store `char c` to `c`
+
-* Casting a `String` reference into a `char` value.
+* Casting a `String` reference into a `char` type value.
+
[source,Painless]
----
@@ -328,11 +332,11 @@ Use the *cast operator* to convert a <> value into a
<2> char c = (char)s;
----
<1> declare `String s`;
- assign `String "s"` to `s`;
+ store `String "s"` to `s`;
<2> declare `char c`
- access `s` -> `String "s"`;
+ load from `s` -> `String "s"`;
explicit cast `String "s"` to `char s` -> `char s`;
- assign `char s` to `c`
+ store `char s` to `c`
[[boxing-unboxing]]
==== Boxing and Unboxing
@@ -343,12 +347,12 @@ reference type to its corresponding primitive type.
Implicit boxing/unboxing occurs during the following operations:
-* Conversions between a `def` type and a primitive type will be implicitly
+* Conversions between a `def` type and a primitive type are implicitly
boxed/unboxed as necessary, though this is referred to as an implicit cast
throughout the documentation.
-* Method/function call arguments will be implicitly boxed/unboxed as necessary.
-* A primitive type value will be implicitly boxed when a reference type method
- call is invoked on it.
+* Method/function call arguments are implicitly boxed/unboxed as necessary.
+* A primitive type value is implicitly boxed when a reference type method
+ is called on it.
Explicit boxing/unboxing is not allowed. Use the reference type API to
explicitly convert a primitive type value to its respective reference type
@@ -372,22 +376,22 @@ value and vice versa.
+
<1> declare `List l`;
allocate `ArrayList` instance -> `ArrayList reference`;
- assign `ArrayList reference` to `l`;
-<2> access `l` -> `List reference`;
+ store `ArrayList reference` to `l`;
+<2> load from `l` -> `List reference`;
implicit cast `int 1` to `def` -> `def`;
call `add` on `List reference` with arguments (`def`);
(note internally `int 1` is boxed to `Integer 1` to store as a `def` type
value)
<3> declare `Integer I`;
call `valueOf` on `Integer` with arguments of (`int 0`) -> `Integer 0`;
- assign `Integer 0` to `I`;
+ store `Integer 0` to `I`;
<4> declare `int i`;
- access `I` -> `Integer 0`;
+ load from `I` -> `Integer 0`;
unbox `Integer 0` -> `int 0`;
- access `l` -> `List reference`;
+ load from `l` -> `List reference`;
call `get` on `List reference` with arguments (`int 0`) -> `def`;
implicit cast `def` to `int 1` -> `int 1`;
- assign `int 1` to `i`;
+ store `int 1` to `i`;
(note internally `int 1` is unboxed from `Integer 1` when loaded from a
`def` type value)
+
@@ -419,8 +423,8 @@ Promotion is when a single value is implicitly cast to a certain type or
multiple values are implicitly cast to the same type as required for evaluation
by certain operations. Each operation that requires promotion has a promotion
table that shows all required implicit casts based on the type(s) of value(s). A
-value can be promoted to a `def` type at compile-time; however, the promoted
-type value is derived from what the `def` type value represents at run-time.
+value promoted to a `def` type at compile-time is promoted again at run-time
+based on the type the `def` value represents.
*Errors*
@@ -438,19 +442,83 @@ type value is derived from what the `def` type value represents at run-time.
<3> float f = x + 2.0F;
----
<1> declare `double d`;
- promote `int 2` and `double 2.0 @0` -> `double 2.0 @0`;
+ promote `int 2` and `double 2.0 @0`: result `double`;
implicit cast `int 2` to `double 2.0 @1` -> `double 2.0 @1`;
add `double 2.0 @1` and `double 2.0 @0` -> `double 4.0`;
- assign `double 4.0` to `d`
+ store `double 4.0` to `d`
<2> declare `def x`;
implicit cast `int 1` to `def` -> `def`;
- assign `def` to `x`;
+ store `def` to `x`;
<3> declare `float f`;
- access `x` -> `def`;
+ load from `x` -> `def`;
implicit cast `def` to `int 1` -> `int 1`;
- promote `int 1` and `float 2.0` -> `float 2.0`;
+ promote `int 1` and `float 2.0`: result `float`;
implicit cast `int 1` to `float 1.0` -> `float `1.0`;
add `float 1.0` and `float 2.0` -> `float 3.0`;
- assign `float 3.0` to `f`;
+ store `float 3.0` to `f`;
(note this example illustrates promotion done at run-time as promotion
done at compile-time would have resolved to a `def` type value)
+
+[[allowed-casts]]
+==== Allowed Casts
+
+The following tables show all allowed casts. Read the tables row by row, where
+the original type is shown in the first column, and each subsequent column
+indicates whether a cast to the specified target type is implicit (I), explicit
+(E), or is not allowed (-).
+
+*Primitive/Reference Types*
+
+[cols="<3,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1"]
+|====
+| | o | b | s | c | i | j | f | d | O | B | S | C | I | L | F | D | T | R | def
+| boolean ( o ) | | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | I
+| byte ( b ) | - | | I | I | I | I | I | I | - | - | - | - | - | - | - | - | - | - | I
+| short ( s ) | - | E | | E | I | I | I | I | - | - | - | - | - | - | - | - | - | - | I
+| char ( c ) | - | E | E | | I | I | I | I | - | - | - | - | - | - | - | - | E | - | I
+| int ( i ) | - | E | E | E | | I | I | I | - | - | - | - | - | - | - | - | - | - | I
+| long ( j ) | - | E | E | E | E | | I | I | - | - | - | - | - | - | - | - | - | - | I
+| float ( f ) | - | E | E | E | E | E | | I | - | - | - | - | - | - | - | - | - | - | I
+| double ( d ) | - | E | E | E | E | E | E | | - | - | - | - | - | - | - | - | - | - | I
+| Boolean ( O ) | - | - | - | - | - | - | - | - | - | - | - | | - | - | - | - | - | - | I
+| Byte ( B ) | - | - | - | - | - | - | - | - | - | | - | - | - | - | - | - | - | - | I
+| Short ( S ) | - | - | - | - | - | - | - | - | - | - | | - | - | - | - | - | - | - | I
+| Character ( C ) | - | - | - | - | - | - | - | - | - | - | - | | - | - | - | - | - | - | I
+| Integer ( I ) | - | - | - | - | - | - | - | - | - | - | - | - | | - | - | - | - | - | I
+| Long ( L ) | - | - | - | - | - | - | - | - | - | - | - | - | - | | - | - | - | - | I
+| Float ( F ) | - | - | - | - | - | - | - | - | - | - | - | - | - | - | | - | - | - | I
+| Double ( D ) | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | | - | - | I
+| String ( T ) | - | - | - | E | - | - | - | - | - | - | - | - | - | - | - | - | | - | I
+| Reference ( R ) | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | @ | I
+|====
+
+@ See <> for allowed reference
+ type casts.
+
+*`def` Type*
+
+[cols="<3,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1"]
+|====
+| | o | b | s | c | i | j | f | d | O | B | S | C | I | L | F | D | T | R | def
+| def as boolean | I | - | - | - | - | - | - | - | I | - | - | - | - | - | - | - | - | - |
+| def as byte | - | I | I | I | I | I | I | I | - | I | I | I | I | I | I | I | - | - |
+| def as short | - | E | I | E | I | I | I | I | - | E | I | E | I | I | I | I | - | - |
+| def as char | - | E | E | I | I | I | I | I | - | E | E | I | I | I | I | I | E | - |
+| def as int | - | E | E | E | I | I | I | I | - | E | E | E | I | I | I | I | - | - |
+| def as long | - | E | E | E | E | I | I | I | - | E | E | E | E | I | I | I | - | - |
+| def as float | - | E | E | E | E | E | I | I | - | E | E | E | E | E | I | I | - | - |
+| def as double | - | E | E | E | E | E | E | I | - | E | E | E | E | E | E | I | - | - |
+| def as Boolean | I | - | - | - | - | - | - | - | I | - | - | - | | - | - | - | - | - |
+| def as Byte | - | I | I | I | I | I | I | I | - | I | I | I | I | I | I | I | - | - |
+| def as Short | - | E | I | E | I | I | I | I | - | E | I | E | I | I | I | I | - | - |
+| def as Character | - | E | E | I | I | I | I | I | - | E | E | I | I | I | I | I | - | - |
+| def as Integer | - | E | E | E | I | I | I | I | - | E | E | E | I | I | I | I | - | - |
+| def as Long | - | E | E | E | E | I | I | I | - | E | E | E | E | I | I | I | - | - |
+| def as Float | - | E | E | E | E | E | I | I | - | E | E | E | E | E | I | I | - | - |
+| def as Double | - | E | E | E | E | E | E | I | - | E | E | E | E | E | E | I | - | - |
+| def as String | - | - | - | E | - | - | - | - | - | - | - | - | - | - | - | - | I | - |
+| def as Reference | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | @ |
+|====
+
+@ See <> for allowed reference
+ type casts.
diff --git a/docs/painless/painless-comments.asciidoc b/docs/painless/painless-comments.asciidoc
index bde30e37e04..bfd3594431e 100644
--- a/docs/painless/painless-comments.asciidoc
+++ b/docs/painless/painless-comments.asciidoc
@@ -6,9 +6,10 @@ anywhere on a line to specify a single-line comment. All characters from the
`//` token to the end of the line are ignored. Use an opening `/*` token and a
closing `*/` token to specify a multi-line comment. Multi-line comments can
start anywhere on a line, and all characters in between the `/*` token and `*/`
-token are ignored. Comments can be included anywhere within a script.
+token are ignored. A comment is included anywhere within a script.
*Grammar*
+
[source,ANTLR4]
----
SINGLE_LINE_COMMENT: '//' .*? [\n\r];
diff --git a/docs/painless/painless-functions.asciidoc b/docs/painless/painless-functions.asciidoc
new file mode 100644
index 00000000000..20f3e821f1e
--- /dev/null
+++ b/docs/painless/painless-functions.asciidoc
@@ -0,0 +1,24 @@
+[[painless-functions]]
+=== Functions
+
+A function is a named piece of code comprised of one-to-many statements to
+perform a specific task. A function is called multiple times in a single script
+to repeat its specific task. A parameter is a named type value available as a
+<> within the statement(s) of a function. A
+function specifies zero-to-many parameters, and when a function is called a
+value is specified per parameter. An argument is a value passed into a function
+at the point of call. A function specifies a return type value, though if the
+type is <> then no value is returned. Any non-void type return
+value is available for use within an <> or is
+discarded otherwise.
+
+You can declare functions at the beginning of a Painless script, for example:
+
+[source,painless]
+---------------------------------------------------------
+boolean isNegative(def x) { x < 0 }
+...
+if (isNegative(someVar)) {
+ ...
+}
+---------------------------------------------------------
\ No newline at end of file
diff --git a/docs/painless/painless-general-syntax.asciidoc b/docs/painless/painless-general-syntax.asciidoc
deleted file mode 100644
index 114bff80bfa..00000000000
--- a/docs/painless/painless-general-syntax.asciidoc
+++ /dev/null
@@ -1,81 +0,0 @@
-[[painless-general-syntax]]
-=== General Syntax
-
-[[control-flow]]
-==== Control flow
-
-Painless supports all of Java's https://docs.oracle.com/javase/tutorial/java/nutsandbolts/flow.html[
-control flow statements] except the `switch` statement.
-
-Painless also supports the `for in` syntax from Groovy:
-
-[source,painless]
----------------------------------------------------------
-for (item : list) {
- ...
-}
----------------------------------------------------------
-
-[[functions]]
-==== Functions
-
-You can declare functions at the beginning of a Painless script, for example:
-
-[source,painless]
----------------------------------------------------------
-boolean isNegative(def x) { x < 0 }
-...
-if (isNegative(someVar)) {
- ...
-}
----------------------------------------------------------
-
-[[lambda-expressions]]
-==== Lambda expressions
-Lambda expressions and method references work the same as in https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html[Java].
-
-[source,painless]
----------------------------------------------------------
-list.removeIf(item -> item == 2);
-list.removeIf((int item) -> item == 2);
-list.removeIf((int item) -> { item == 2 });
-list.sort((x, y) -> x - y);
-list.sort(Integer::compare);
----------------------------------------------------------
-
-You can make method references to functions within the script with `this`,
-for example `list.sort(this::mycompare)`.
-
-[[patterns]]
-==== Patterns
-
-Regular expression constants are directly supported. To ensure fast performance,
-this is the only mechanism for creating patterns. Regular expressions
-are always constants and compiled efficiently a single time.
-
-[source,painless]
----------------------------------------------------------
-Pattern p = /[aeiou]/
----------------------------------------------------------
-
-[[pattern-flags]]
-===== Pattern flags
-
-You can define flags on patterns in Painless by adding characters after the
-trailing `/` like `/foo/i` or `/foo \w #comment/iUx`. Painless exposes all of
-the flags from Java's
-https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html[
-Pattern class] using these characters:
-
-[cols="<,<,<",options="header",]
-|=======================================================================
-| Character | Java Constant | Example
-|`c` | CANON_EQ | `'å' ==~ /å/c` (open in hex editor to see)
-|`i` | CASE_INSENSITIVE | `'A' ==~ /a/i`
-|`l` | LITERAL | `'[a]' ==~ /[a]/l`
-|`m` | MULTILINE | `'a\nb\nc' =~ /^b$/m`
-|`s` | DOTALL (aka single line) | `'a\nb\nc' =~ /.b./s`
-|`U` | UNICODE_CHARACTER_CLASS | `'Ɛ' ==~ /\\w/U`
-|`u` | UNICODE_CASE | `'Ɛ' ==~ /ɛ/iu`
-|`x` | COMMENTS (aka extended) | `'a' ==~ /a #comment/x`
-|=======================================================================
diff --git a/docs/painless/painless-identifiers.asciidoc b/docs/painless/painless-identifiers.asciidoc
index 7762f56cb7b..d2678b528ea 100644
--- a/docs/painless/painless-identifiers.asciidoc
+++ b/docs/painless/painless-identifiers.asciidoc
@@ -3,8 +3,12 @@
Use an identifier as a named token to specify a
<>, <>,
-<>, <>, or function.
-<> cannot be used as identifiers.
+<>, <>, or
+<>.
+
+*Errors*
+
+If a <> is used as an identifier.
*Grammar*
[source,ANTLR4]
diff --git a/docs/painless/painless-keywords.asciidoc b/docs/painless/painless-keywords.asciidoc
index 39a2201fd2b..9463902c8d3 100644
--- a/docs/painless/painless-keywords.asciidoc
+++ b/docs/painless/painless-keywords.asciidoc
@@ -1,9 +1,13 @@
[[painless-keywords]]
=== Keywords
-Keywords are reserved tokens for built-in language features and cannot be used
-as <> within a script. The following are
-keywords:
+Keywords are reserved tokens for built-in language features.
+
+*Errors*
+
+If a keyword is used as an <>.
+
+*Keywords*
[cols="^1,^1,^1,^1,^1"]
|====
diff --git a/docs/painless/painless-lambdas.asciidoc b/docs/painless/painless-lambdas.asciidoc
new file mode 100644
index 00000000000..e6694229a0c
--- /dev/null
+++ b/docs/painless/painless-lambdas.asciidoc
@@ -0,0 +1,15 @@
+[[painless-lambdas]]
+=== Lambdas
+Lambda expressions and method references work the same as in https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html[Java].
+
+[source,painless]
+---------------------------------------------------------
+list.removeIf(item -> item == 2);
+list.removeIf((int item) -> item == 2);
+list.removeIf((int item) -> { item == 2 });
+list.sort((x, y) -> x - y);
+list.sort(Integer::compare);
+---------------------------------------------------------
+
+You can make method references to functions within the script with `this`,
+for example `list.sort(this::mycompare)`.
\ No newline at end of file
diff --git a/docs/painless/painless-lang-spec.asciidoc b/docs/painless/painless-lang-spec.asciidoc
index 5e6b84d8c57..d50f3db2dc0 100644
--- a/docs/painless/painless-lang-spec.asciidoc
+++ b/docs/painless/painless-lang-spec.asciidoc
@@ -33,4 +33,22 @@ include::painless-casting.asciidoc[]
include::painless-operators.asciidoc[]
-include::painless-general-syntax.asciidoc[]
+include::painless-operators-general.asciidoc[]
+
+include::painless-operators-numeric.asciidoc[]
+
+include::painless-operators-boolean.asciidoc[]
+
+include::painless-operators-reference.asciidoc[]
+
+include::painless-operators-array.asciidoc[]
+
+include::painless-statements.asciidoc[]
+
+include::painless-scripts.asciidoc[]
+
+include::painless-functions.asciidoc[]
+
+include::painless-lambdas.asciidoc[]
+
+include::painless-regexes.asciidoc[]
diff --git a/docs/painless/painless-literals.asciidoc b/docs/painless/painless-literals.asciidoc
index ebf7eaa07b6..621fc152be9 100644
--- a/docs/painless/painless-literals.asciidoc
+++ b/docs/painless/painless-literals.asciidoc
@@ -4,7 +4,7 @@
Use a literal to specify a value directly in an
<>.
-[[integers]]
+[[integer-literals]]
==== Integers
Use an integer literal to specify an integer type value in decimal, octal, or
@@ -16,6 +16,7 @@ to specify an integer literal as octal, and use `0x` or `0X` as a prefix to
specify an integer literal as hex.
*Grammar*
+
[source,ANTLR4]
----
INTEGER: '-'? ( '0' | [1-9] [0-9]* ) [lLfFdD]?;
@@ -44,7 +45,7 @@ HEX: '-'? '0' [xX] [0-9a-fA-F]+ [lL]?;
<5> `int -18` in octal
<6> `int 3882` in hex
-[[floats]]
+[[float-literals]]
==== Floats
Use a floating point literal to specify a floating point type value of a
@@ -53,6 +54,7 @@ single letter designations to specify the primitive type: `f` or `F` for `float`
and `d` or `D` for `double`. If not specified, the type defaults to `double`.
*Grammar*
+
[source,ANTLR4]
----
DECIMAL: '-'? ( '0' | [1-9] [0-9]* ) (DOT [0-9]+)? EXPONENT? [fFdD]?;
@@ -78,7 +80,7 @@ EXPONENT: ( [eE] [+\-]? [0-9]+ );
<4> `double -126.34`
<5> `float 89.9`
-[[strings]]
+[[string-literals]]
==== Strings
Use a string literal to specify a <> value with
@@ -88,6 +90,7 @@ include a single-quote as part of a single-quoted string literal. Use a `\\`
token to include a backslash as part of any string literal.
*Grammar*
+
[source,ANTLR4]
----
STRING: ( '"' ( '\\"' | '\\\\' | ~[\\"] )*? '"' )
@@ -114,9 +117,9 @@ STRING: ( '"' ( '\\"' | '\\\\' | ~[\\"] )*? '"' )
"double-quoted with non-escaped 'single-quotes'"
----
-[[characters]]
+[[character-literals]]
==== Characters
-A character literal cannot be specified directly. Instead, use the
+Character literals are not specified directly. Instead, use the
<> to convert a `String` type value
into a `char` type value.
diff --git a/docs/painless/painless-operators-array.asciidoc b/docs/painless/painless-operators-array.asciidoc
new file mode 100644
index 00000000000..e91c07acef5
--- /dev/null
+++ b/docs/painless/painless-operators-array.asciidoc
@@ -0,0 +1,294 @@
+[[painless-operators-array]]
+=== Operators: Array
+
+[[array-initialization-operator]]
+==== Array Initialization
+
+Use the `array initialization operator '[] {}'` to allocate a single-dimensional
+<> instance to the heap with a set of pre-defined
+elements. Each value used to initialize an element in the array type instance is
+cast to the specified element type value upon insertion. The order of specified
+values is maintained.
+
+*Errors*
+
+* If a value is not castable to the specified type value.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+array_initialization: 'new' TYPE '[' ']' '{' expression_list '}'
+ | 'new' TYPE '[' ']' '{' '}';
+expression_list: expression (',' expression);
+----
+
+*Example:*
+
+* Array initialization with static values.
++
+[source,Painless]
+----
+<1> int[] x = new int[] {1, 2, 3};
+----
++
+<1> declare `int[] x`;
+ allocate `1-d int array` instance with `length [3]`
+ -> `1-d int array reference`;
+ store `int 1` to `index [0]` of `1-d int array reference`;
+ store `int 2` to `index [1]` of `1-d int array reference`;
+ store `int 3` to `index [2]` of `1-d int array reference`;
+ store `1-d int array reference` to `x`;
++
+* Array initialization with non-static values.
++
+[source,Painless]
+----
+<1> int i = 1;
+<2> long l = 2L;
+<3> float f = 3.0F;
+<4> double d = 4.0;
+<5> String s = "5";
+<6> def array = new def[] {i, l, f*d, s};
+----
++
+<1> declare `int i`;
+ store `int 1` to `i`
+<2> declare `long l`;
+ store `long 2` to `l`
+<3> declare `float f`;
+ store `float 3.0` to `f`
+<4> declare `double d`;
+ store `double 4.0` to `d`
+<5> declare `String s`;
+ store `String "5"` to `s`
+<6> declare `def array`;
+ allocate `1-d def array` instance with `length [4]`
+ -> `1-d def array reference`;
+ load from `i` -> `int 1`;
+ implicit cast `int 1` to `def` -> `def`;
+ store `def` to `index [0]` of `1-d def array reference`;
+ load from `l` -> `long 2`;
+ implicit cast `long 2` to `def` -> `def`;
+ store `def` to `index [1]` of `1-d def array reference`;
+ load from `f` -> `float 3.0`;
+ load from `d` -> `double 4.0`;
+ promote `float 3.0` and `double 4.0`: result `double`;
+ implicit cast `float 3.0` to `double 3.0` -> `double 3.0`;
+ multiply `double 3.0` and `double 4.0` -> `double 12.0`;
+ implicit cast `double 12.0` to `def` -> `def`;
+ store `def` to `index [2]` of `1-d def array reference`;
+ load from `s` -> `String "5"`;
+ implicit cast `String "5"` to `def` -> `def`;
+ store `def` to `index [3]` of `1-d def array reference`;
+ implicit cast `1-d int array reference` to `def` -> `def`;
+ store `def` to `array`
+
+[[array-access-operator]]
+==== Array Access
+
+Use the `array access operator '[]'` to store a value to or load a value from
+an <> value. Each element of an array type value is
+accessed with an `int` type value to specify the index to store/load. The range
+of elements within an array that are accessible is `[0, size)` where size is the
+number of elements specified at the time of allocation. Use a negative `int`
+type value as an index to access an element in reverse from the end of an array
+type value within a range of `[-size, -1]`.
+
+*Errors*
+
+* If a value other than an `int` type value or a value that is castable to an
+ `int` type value is provided as an index.
+* If an element is accessed outside of the valid ranges.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+brace_access: '[' expression ']'
+----
+
+*Examples*
+
+* Array access with a single-dimensional array.
++
+[source,Painless]
+----
+<1> int[] x = new int[2];
+<2> x[0] = 2;
+<3> x[1] = 5;
+<4> int y = x[0] + x[1];
+<5> int z = 1;
+<6> int i = x[z];
+----
++
+<1> declare `int[] x`;
+ allocate `1-d int array` instance with `length [2]`
+ -> `1-d int array reference`;
+ store `1-d int array reference` to `x`
+<2> load from `x` -> `1-d int array reference`;
+ store `int 2` to `index [0]` of `1-d int array reference`;
+<3> load from `x` -> `1-d int array reference`;
+ store `int 5` to `index [1]` of `1-d int array reference`;
+<4> declare `int y`;
+ load from `x` -> `1-d int array reference`;
+ load from `index [0]` of `1-d int array reference` -> `int 2`;
+ load from `x` -> `1-d int array reference`;
+ load from `index [1]` of `1-d int array reference` -> `int 5`;
+ add `int 2` and `int 5` -> `int 7`;
+ store `int 7` to `y`
+<5> declare `int z`;
+ store `int 1` to `z`;
+<6> declare `int i`;
+ load from `x` -> `1-d int array reference`;
+ load from `z` -> `int 1`;
+ load from `index [1]` of `1-d int array reference` -> `int 5`;
+ store `int 5` to `i`;
++
+* Array access with the `def` type.
++
+[source,Painless]
+----
+<1> def d = new int[2];
+<2> d[0] = 2;
+<3> d[1] = 5;
+<4> def x = d[0] + d[1];
+<5> def y = 1;
+<6> def z = d[y];
+----
++
+<1> declare `def d`;
+ allocate `1-d int array` instance with `length [2]`
+ -> `1-d int array reference`;
+ implicit cast `1-d int array reference` to `def` -> `def`;
+ store `def` to `d`
+<2> load from `d` -> `def`
+ implicit cast `def` to `1-d int array reference`
+ -> `1-d int array reference`;
+ store `int 2` to `index [0]` of `1-d int array reference`;
+<3> load from `d` -> `def`
+ implicit cast `def` to `1-d int array reference`
+ -> `1-d int array reference`;
+ store `int 5` to `index [1]` of `1-d int array reference`;
+<4> declare `int x`;
+ load from `d` -> `def`
+ implicit cast `def` to `1-d int array reference`
+ -> `1-d int array reference`;
+ load from `index [0]` of `1-d int array reference` -> `int 2`;
+ load from `d` -> `def`
+ implicit cast `def` to `1-d int array reference`
+ -> `1-d int array reference`;
+ load from `index [1]` of `1-d int array reference` -> `int 5`;
+ add `int 2` and `int 5` -> `int 7`;
+ implicit cast `int 7` to `def` -> `def`;
+ store `def` to `x`
+<5> declare `def y`;
+ implicit cast `int 1` to `def` -> `def`;
+ store `def ` to `y`;
+<6> declare `int i`;
+ load from `d` -> `def`
+ implicit cast `def` to `1-d int array reference`
+ -> `1-d int array reference`;
+ load from `y` -> `def`;
+ implicit cast `def` to `int 1` -> `int 1`;
+ load from `index [1]` of `1-d int array reference` -> `int 5`;
+ implicit cast `int 5` to `def`;
+ store `def` to `z`;
++
+* Array access with a multi-dimensional array.
++
+[source,Painless]
+----
+<1> int[][][] ia3 = new int[2][3][4];
+<2> ia3[1][2][3] = 99;
+<3> int i = ia3[1][2][3];
+----
++
+<1> declare `int[][][] ia`;
+ allocate `3-d int array` instance with length `[2, 3, 4]`
+ -> `3-d int array reference`;
+ store `3-d int array reference` to `ia3`
+<2> load from `ia3` -> `3-d int array reference`;
+ store `int 99` to `index [1, 2, 3]` of `3-d int array reference`
+<3> declare `int i`;
+ load from `ia3` -> `3-d int array reference`;
+ load from `index [1, 2, 3]` of `3-d int array reference` -> `int 99`;
+ store `int 99` to `i`
+
+[[array-length-operator]]
+==== Array Length
+
+An array type value contains a read-only member field named `length`. The
+`length` field stores the size of the array as an `int` type value where size is
+the number of elements specified at the time of allocation. Use the
+<> to load the field `length`
+from an array type value.
+
+*Examples*
+
+* Access the `length` field.
++
+[source,Painless]
+----
+<1> int[] x = new int[10];
+<2> int l = x.length;
+----
+<1> declare `int[] x`;
+ allocate `1-d int array` instance with `length [2]`
+ -> `1-d int array reference`;
+ store `1-d int array reference` to `x`
+<2> declare `int l`;
+ load `x` -> `1-d int array reference`;
+ load `length` from `1-d int array reference` -> `int 10`;
+ store `int 10` to `l`;
+
+[[new-array-operator]]
+==== New Array
+
+Use the `new array operator 'new []'` to allocate an array type instance to
+the heap. Specify the element type following the `new` token. Specify each
+dimension with the `[` and `]` tokens following the element type name. The size
+of each dimension is specified by an `int` type value in between each set of `[`
+and `]` tokens.
+
+*Errors*
+
+* If a value other than an `int` type value or a value that is castable to an
+ `int` type value is specified for for a dimension's size.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+new_array: 'new' TYPE ('[' expression ']')+;
+----
+
+*Examples*
+
+* Allocation of different array types.
++
+[source,Painless]
+----
+<1> int[] x = new int[5];
+<2> x = new int[10];
+<3> int y = 2;
+<4> def z = new def[y][y*2];
+----
++
+<1> declare `int[] x`;
+ allocate `1-d int array` instance with `length [5]`
+ -> `1-d int array reference`;
+ store `1-d int array reference` to `x`
+<2> allocate `1-d int array` instance with `length [10]`
+ -> `1-d int array reference`;
+ store `1-d int array reference` to `x`
+<3> declare `int y`;
+ store `int 2` to `y`;
+<4> declare `def z`;
+ load from `y` -> `int 2 @0`;
+ load from `y` -> `int 2 @1`;
+ multiply `int 2 @1` by `int 2 @2` -> `int 4`;
+ allocate `2-d int array` instance with length `[2, 4]`
+ -> `2-d int array reference`;
+ implicit cast `2-d int array reference` to `def` -> `def`;
+ store `def` to `z`;
diff --git a/docs/painless/painless-operators-boolean.asciidoc b/docs/painless/painless-operators-boolean.asciidoc
new file mode 100644
index 00000000000..1223a8d56e7
--- /dev/null
+++ b/docs/painless/painless-operators-boolean.asciidoc
@@ -0,0 +1,1420 @@
+[[painless-operators-boolean]]
+=== Operators: Boolean
+
+[[boolean-not-operator]]
+==== Boolean Not
+
+Use the `boolean not operator '!'` to NOT a `boolean` type value where `true` is
+flipped to `false` and `false` is flipped to `true`.
+
+*Errors*
+
+* If a value other than a `boolean` type value or a value that is castable to a
+ `boolean` type value is given.
+
+*Truth*
+
+[options="header",cols="<1,<1"]
+|====
+| original | result
+| true | false
+| false | true
+|====
+
+*Grammar*
+
+[source,ANTLR4]
+----
+boolean_not: '!' expression;
+----
+
+*Examples*
+
+* Boolean not with the `boolean` type.
++
+[source,Painless]
+----
+<1> boolean x = !false;
+<2> boolean y = !x;
+----
+<1> declare `boolean x`;
+ boolean not `boolean false` -> `boolean true`;
+ store `boolean true` to `x`
+<2> declare `boolean y`;
+ load from `x` -> `boolean true`;
+ boolean not `boolean true` -> `boolean false`;
+ store `boolean false` to `y`
++
+* Boolean not with the `def` type.
++
+[source,Painless]
+----
+<1> def y = true;
+<2> def z = !y;
+----
++
+<1> declare `def y`;
+ implicit cast `boolean true` to `def` -> `def`;
+ store `true` to `y`
+<2> declare `def z`;
+ load from `y` -> `def`;
+ implicit cast `def` to `boolean true` -> boolean `true`;
+ boolean not `boolean true` -> `boolean false`;
+ implicit cast `boolean false` to `def` -> `def`;
+ store `def` to `z`
+
+[[greater-than-operator]]
+==== Greater Than
+
+Use the `greater than operator '>'` to COMPARE two numeric type values where a
+resultant `boolean` type value is `true` if the left-hand side value is greater
+than to the right-hand side value and `false` otherwise.
+
+*Errors*
+
+* If either the evaluated left-hand side or the evaluated right-hand side is a
+ non-numeric value.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+greater_than: expression '>' expression;
+----
+
+*Promotion*
+
+[cols="<1,^1,^1,^1,^1,^1,^1,^1,^1"]
+|====
+| | byte | short | char | int | long | float | double | def
+| byte | int | int | int | int | long | float | double | def
+| short | int | int | int | int | long | float | double | def
+| char | int | int | int | int | long | float | double | def
+| int | int | int | int | int | long | float | double | def
+| long | long | long | long | long | long | float | double | def
+| float | float | float | float | float | float | float | double | def
+| double | double | double | double | double | double | double | double | def
+| def | def | def | def | def | def | def | def | def
+|====
+
+*Examples*
+
+* Greater than with different numeric types.
++
+[source,Painless]
+----
+<1> boolean x = 5 > 4;
+<2> double y = 6.0;
+<3> x = 6 > y;
+----
++
+<1> declare `boolean x`;
+ greater than `int 5` and `int 4` -> `boolean true`;
+ store `boolean true` to `x`;
+<2> declare `double y`;
+ store `double 6.0` to `y`;
+<3> load from `y` -> `double 6.0 @0`;
+ promote `int 6` and `double 6.0`: result `double`;
+ implicit cast `int 6` to `double 6.0 @1` -> `double 6.0 @1`;
+ greater than `double 6.0 @1` and `double 6.0 @0` -> `boolean false`;
+ store `boolean false` to `x`
++
+* Greater than with `def` type.
++
+[source,Painless]
+----
+<1> int x = 5;
+<2> def y = 7.0;
+<3> def z = y > 6.5;
+<4> def a = x > y;
+----
++
+<1> declare `int x`;
+ store `int 5` to `x`
+<2> declare `def y`;
+ implicit cast `double 7.0` to `def` -> `def`;
+ store `def` to `y`
+<3> declare `def z`;
+ load from `y` -> `def`;
+ implicit cast `def` to `double 7.0` -> `double 7.0`;
+ greater than `double 7.0` and `double 6.5` -> `boolean true`;
+ implicit cast `boolean true` to `def` -> `def`;
+ store `def` to `z`
+<4> declare `def a`;
+ load from `y` -> `def`;
+ implicit cast `def` to `double 7.0` -> `double 7.0`;
+ load from `x` -> `int 5`;
+ promote `int 5` and `double 7.0`: result `double`;
+ implicit cast `int 5` to `double 5.0` -> `double 5.0`;
+ greater than `double 5.0` and `double 7.0` -> `boolean false`;
+ implicit cast `boolean false` to `def` -> `def`;
+ store `def` to `z`
+
+[[greater-than-or-equal-operator]]
+==== Greater Than Or Equal
+
+Use the `greater than or equal operator '>='` to COMPARE two numeric type values
+where a resultant `boolean` type value is `true` if the left-hand side value is
+greater than or equal to the right-hand side value and `false` otherwise.
+
+*Errors*
+
+* If either the evaluated left-hand side or the evaluated right-hand side is a
+ non-numeric value.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+greater_than_or_equal: expression '>=' expression;
+----
+
+*Promotion*
+
+[cols="<1,^1,^1,^1,^1,^1,^1,^1,^1"]
+|====
+| | byte | short | char | int | long | float | double | def
+| byte | int | int | int | int | long | float | double | def
+| short | int | int | int | int | long | float | double | def
+| char | int | int | int | int | long | float | double | def
+| int | int | int | int | int | long | float | double | def
+| long | long | long | long | long | long | float | double | def
+| float | float | float | float | float | float | float | double | def
+| double | double | double | double | double | double | double | double | def
+| def | def | def | def | def | def | def | def | def
+|====
+
+*Examples*
+
+* Greater than or equal with different numeric types.
++
+[source,Painless]
+----
+<1> boolean x = 5 >= 4;
+<2> double y = 6.0;
+<3> x = 6 >= y;
+----
++
+<1> declare `boolean x`;
+ greater than or equal `int 5` and `int 4` -> `boolean true`;
+ store `boolean true` to `x`
+<2> declare `double y`;
+ store `double 6.0` to `y`
+<3> load from `y` -> `double 6.0 @0`;
+ promote `int 6` and `double 6.0`: result `double`;
+ implicit cast `int 6` to `double 6.0 @1` -> `double 6.0 @1`;
+ greater than or equal `double 6.0 @1` and `double 6.0 @0` -> `boolean true`;
+ store `boolean true` to `x`
++
+* Greater than or equal with the `def` type.
++
+[source,Painless]
+----
+<1> int x = 5;
+<2> def y = 7.0;
+<3> def z = y >= 7.0;
+<4> def a = x >= y;
+----
++
+<1> declare `int x`;
+ store `int 5` to `x`;
+<2> declare `def y`
+ implicit cast `double 7.0` to `def` -> `def`;
+ store `def` to `y`
+<3> declare `def z`;
+ load from `y` -> `def`;
+ implicit cast `def` to `double 7.0 @0` -> `double 7.0 @0`;
+ greater than or equal `double 7.0 @0` and `double 7.0 @1` -> `boolean true`;
+ implicit cast `boolean true` to `def` -> `def`;
+ store `def` to `z`
+<4> declare `def a`;
+ load from `y` -> `def`;
+ implicit cast `def` to `double 7.0` -> `double 7.0`;
+ load from `x` -> `int 5`;
+ promote `int 5` and `double 7.0`: result `double`;
+ implicit cast `int 5` to `double 5.0` -> `double 5.0`;
+ greater than or equal `double 5.0` and `double 7.0` -> `boolean false`;
+ implicit cast `boolean false` to `def` -> `def`;
+ store `def` to `z`
+
+[[less-than-operator]]
+==== Less Than
+
+Use the `less than operator '<'` to COMPARE two numeric type values where a
+resultant `boolean` type value is `true` if the left-hand side value is less
+than to the right-hand side value and `false` otherwise.
+
+*Errors*
+
+* If either the evaluated left-hand side or the evaluated right-hand side is a
+ non-numeric value.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+less_than: expression '<' expression;
+----
+
+*Promotion*
+
+[cols="<1,^1,^1,^1,^1,^1,^1,^1,^1"]
+|====
+| | byte | short | char | int | long | float | double | def
+| byte | int | int | int | int | long | float | double | def
+| short | int | int | int | int | long | float | double | def
+| char | int | int | int | int | long | float | double | def
+| int | int | int | int | int | long | float | double | def
+| long | long | long | long | long | long | float | double | def
+| float | float | float | float | float | float | float | double | def
+| double | double | double | double | double | double | double | double | def
+| def | def | def | def | def | def | def | def | def
+|====
+
+*Examples*
+
+* Less than with different numeric types.
++
+[source,Painless]
+----
+<1> boolean x = 5 < 4;
+<2> double y = 6.0;
+<3> x = 6 < y;
+----
++
+<1> declare `boolean x`;
+ less than `int 5` and `int 4` -> `boolean false`;
+ store `boolean false` to `x`
+<2> declare `double y`;
+ store `double 6.0` to `y`
+<3> load from `y` -> `double 6.0 @0`;
+ promote `int 6` and `double 6.0`: result `double`;
+ implicit cast `int 6` to `double 6.0 @1` -> `double 6.0 @1`;
+ less than `double 6.0 @1` and `double 6.0 @0` -> `boolean false`;
+ store `boolean false` to `x`
++
+* Less than with the `def` type.
++
+[source,Painless]
+----
+<1> int x = 5;
+<2> def y = 7.0;
+<3> def z = y < 6.5;
+<4> def a = x < y;
+----
++
+<1> declare `int x`;
+ store `int 5` to `x`
+<2> declare `def y`;
+ implicit cast `double 7.0` to `def` -> `def`;
+ store `def` to `y`
+<3> declare `def z`;
+ load from `y` -> `def`;
+ implicit cast `def` to `double 7.0` -> `double 7.0`;
+ less than `double 7.0` and `double 6.5` -> `boolean false`;
+ implicit cast `boolean false` to `def` -> `def`;
+ store `def` to `z`
+<4> declare `def a`;
+ load from `y` -> `def`;
+ implicit cast `def` to `double 7.0` -> `double 7.0`;
+ load from `x` -> `int 5`;
+ promote `int 5` and `double 7.0`: result `double`;
+ implicit cast `int 5` to `double 5.0` -> `double 5.0`;
+ less than `double 5.0` and `double 7.0` -> `boolean true`;
+ implicit cast `boolean true` to `def` -> `def`;
+ store `def` to `z`
+
+[[less-than-or-equal-operator]]
+==== Less Than Or Equal
+
+Use the `less than or equal operator '<='` to COMPARE two numeric type values
+where a resultant `boolean` type value is `true` if the left-hand side value is
+less than or equal to the right-hand side value and `false` otherwise.
+
+*Errors*
+
+* If either the evaluated left-hand side or the evaluated right-hand side is a
+ non-numeric value.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+greater_than_or_equal: expression '<=' expression;
+----
+
+*Promotion*
+
+[cols="<1,^1,^1,^1,^1,^1,^1,^1,^1"]
+|====
+| | byte | short | char | int | long | float | double | def
+| byte | int | int | int | int | long | float | double | def
+| short | int | int | int | int | long | float | double | def
+| char | int | int | int | int | long | float | double | def
+| int | int | int | int | int | long | float | double | def
+| long | long | long | long | long | long | float | double | def
+| float | float | float | float | float | float | float | double | def
+| double | double | double | double | double | double | double | double | def
+| def | def | def | def | def | def | def | def | def
+|====
+
+*Examples*
+
+* Less than or equal with different numeric types.
++
+[source,Painless]
+----
+<1> boolean x = 5 <= 4;
+<2> double y = 6.0;
+<3> x = 6 <= y;
+----
++
+<1> declare `boolean x`;
+ less than or equal `int 5` and `int 4` -> `boolean false`;
+ store `boolean true` to `x`
+<2> declare `double y`;
+ store `double 6.0` to `y`
+<3> load from `y` -> `double 6.0 @0`;
+ promote `int 6` and `double 6.0`: result `double`;
+ implicit cast `int 6` to `double 6.0 @1` -> `double 6.0 @1`;
+ less than or equal `double 6.0 @1` and `double 6.0 @0` -> `boolean true`;
+ store `boolean true` to `x`
++
+* Less than or equal with the `def` type.
++
+[source,Painless]
+----
+<1> int x = 5;
+<2> def y = 7.0;
+<3> def z = y <= 7.0;
+<4> def a = x <= y;
+----
++
+<1> declare `int x`;
+ store `int 5` to `x`;
+<2> declare `def y`;
+ implicit cast `double 7.0` to `def` -> `def`;
+ store `def` to `y`;
+<3> declare `def z`;
+ load from `y` -> `def`;
+ implicit cast `def` to `double 7.0 @0` -> `double 7.0 @0`;
+ less than or equal `double 7.0 @0` and `double 7.0 @1` -> `boolean true`;
+ implicit cast `boolean true` to `def` -> `def`;
+ store `def` to `z`
+<4> declare `def a`;
+ load from `y` -> `def`;
+ implicit cast `def` to `double 7.0` -> `double 7.0`;
+ load from `x` -> `int 5`;
+ promote `int 5` and `double 7.0`: result `double`;
+ implicit cast `int 5` to `double 5.0` -> `double 5.0`;
+ less than or equal `double 5.0` and `double 7.0` -> `boolean true`;
+ implicit cast `boolean true` to `def` -> `def`;
+ store `def` to `z`
+
+[[instanceof-operator]]
+==== Instanceof
+
+Use the `instanceof operator` to COMPARE the variable/field type to a
+specified reference type using the reference type name where a resultant
+`boolean` type value is `true` if the variable/field type is the same as or a
+descendant of the specified reference type and false otherwise.
+
+*Errors*
+
+* If the reference type name doesn't exist as specified by the right-hand side.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+instance_of: ID 'instanceof' TYPE;
+----
+
+*Examples*
+
+* Instance of with different reference types.
++
+[source,Painless]
+----
+<1> Map m = new HashMap();
+<2> boolean a = m instanceof HashMap;
+<3> boolean b = m instanceof Map;
+----
++
+<1> declare `Map m`;
+ allocate `HashMap` instance -> `HashMap reference`;
+ implicit cast `HashMap reference` to `Map reference`;
+ store `Map reference` to `m`
+<2> declare `boolean a`;
+ load from `m` -> `Map reference`;
+ implicit cast `Map reference` to `HashMap reference` -> `HashMap reference`;
+ instanceof `HashMap reference` and `HashMap` -> `boolean true`;
+ store `boolean true` to `a`
+<3> declare `boolean b`;
+ load from `m` -> `Map reference`;
+ implicit cast `Map reference` to `HashMap reference` -> `HashMap reference`;
+ instanceof `HashMap reference` and `Map` -> `boolean true`;
+ store `true` to `b`;
+ (note `HashMap` is a descendant of `Map`)
++
+* Instance of with the `def` type.
++
+[source,Painless]
+----
+<1> def d = new ArrayList();
+<2> boolean a = d instanceof List;
+<3> boolean b = d instanceof Map;
+----
++
+<1> declare `def d`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `def` -> `def`;
+ store `def` to `d`
+<2> declare `boolean a`;
+ load from `d` -> `def`;
+ implicit cast `def` to `ArrayList reference` -> `ArrayList reference`;
+ instanceof `ArrayList reference` and `List` -> `boolean true`;
+ store `boolean true` to `a`;
+ (note `ArrayList` is a descendant of `List`)
+<3> declare `boolean b`;
+ load from `d` -> `def`;
+ implicit cast `def` to `ArrayList reference` -> `ArrayList reference`;
+ instanceof `ArrayList reference` and `Map` -> `boolean false`;
+ store `boolean false` to `a`;
+ (note `ArrayList` is not a descendant of `Map`)
+
+[[equality-equals-operator]]
+==== Equality Equals
+
+Use the `equality equals operator '=='` to COMPARE two values where a resultant
+`boolean` type value is `true` if the two values are equal and `false`
+otherwise. The member method, `equals`, is implicitly called when the values are
+reference type values where the first value is the target of the call and the
+second value is the argument. This operation is null-safe where if both values
+are `null` the resultant `boolean` type value is `true`, and if only one value
+is `null` the resultant `boolean` type value is `false`. A valid comparison is
+between `boolean` type values, numeric type values, or reference type values.
+
+*Errors*
+
+* If a comparison is made between a `boolean` type value and numeric type value.
+* If a comparison is made between a primitive type value and a reference type
+ value.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+equality_equals: expression '==' expression;
+----
+
+*Promotion*
+
+[cols="<1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1"]
+|====
+| | boolean | byte | short | char | int | long | float | double | Reference | def
+| boolean | boolean | - | - | - | - | - | - | - | - | def
+| byte | - | int | int | int | int | long | float | double | - | def
+| short | - | int | int | int | int | long | float | double | - | def
+| char | - | int | int | int | int | long | float | double | - | def
+| int | - | int | int | int | int | long | float | double | - | def
+| long | - | long | long | long | long | long | float | double | - | def
+| float | - | float | float | float | float | float | float | double | - | def
+| double | - | double | double | double | double | double | double | double | - | def
+| Reference | - | - | - | - | - | - | - | - | Object | def
+| def | def | def | def | def | def | def | def | def | def | def
+|====
+
+*Examples*
+
+* Equality equals with the `boolean` type.
++
+[source,Painless]
+----
+<1> boolean a = true;
+<2> boolean b = false;
+<3> a = a == false;
+<4> b = a == b;
+----
++
+<1> declare `boolean a`;
+ store `boolean true` to `a`
+<2> declare `boolean b`;
+ store `boolean false` to `b`
+<3> load from `a` -> `boolean true`;
+ equality equals `boolean true` and `boolean false` -> `boolean false`;
+ store `boolean false` to `a`
+<4> load from `a` -> `boolean false @0`;
+ load from `b` -> `boolean false @1`;
+ equality equals `boolean false @0` and `boolean false @1`
+ -> `boolean false`;
+ store `boolean false` to `b`
++
+* Equality equals with primitive types.
++
+[source,Painless]
+----
+<1> int a = 1;
+<2> double b = 2.0;
+<3> boolean c = a == b;
+<4> c = 1 == a;
+----
++
+<1> declare `int a`;
+ store `int 1` to `a`
+<2> declare `double b`;
+ store `double 1.0` to `b`
+<3> declare `boolean c`;
+ load from `a` -> `int 1`;
+ load from `b` -> `double 2.0`;
+ promote `int 1` and `double 2.0`: result `double`;
+ implicit cast `int 1` to `double 1.0` -> `double `1.0`;
+ equality equals `double 1.0` and `double 2.0` -> `boolean false`;
+ store `boolean false` to `c`
+<4> load from `a` -> `int 1 @1`;
+ equality equals `int 1 @0` and `int 1 @1` -> `boolean true`;
+ store `boolean true` to `c`
++
+* Equal equals with reference types.
++
+[source,Painless]
+----
+<1> List a = new ArrayList();
+<2> List b = new ArrayList();
+<3> a.add(1);
+<4> boolean c = a == b;
+<5> b.add(1);
+<6> c = a == b;
+----
++
+<1> declare `List a`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `List reference` -> `List reference`;
+ store `List reference` to `a`
+<2> declare `List b`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `List reference` -> `List reference`;
+ store `List reference` to `b`
+<3> load from `a` -> `List reference`;
+ call `add` on `List reference` with arguments (`int 1)`
+<4> declare `boolean c`;
+ load from `a` -> `List reference @0`;
+ load from `b` -> `List reference @1`;
+ call `equals` on `List reference @0` with arguments (`List reference @1`)
+ -> `boolean false`;
+ store `boolean false` to `c`
+<5> load from `b` -> `List reference`;
+ call `add` on `List reference` with arguments (`int 1`)
+<6> load from `a` -> `List reference @0`;
+ load from `b` -> `List reference @1`;
+ call `equals` on `List reference @0` with arguments (`List reference @1`)
+ -> `boolean true`;
+ store `boolean true` to `c`
++
+* Equality equals with `null`.
++
+[source,Painless]
+----
+<1> Object a = null;
+<2> Object b = null;
+<3> boolean c = a == null;
+<4> c = a == b;
+<5> b = new Object();
+<6> c = a == b;
+----
++
+<1> declare `Object a`;
+ store `null` to `a`
+<2> declare `Object b`;
+ store `null` to `b`
+<3> declare `boolean c`;
+ load from `a` -> `null @0`;
+ equality equals `null @0` and `null @1` -> `boolean true`;
+ store `boolean true` to `c`
+<4> load from `a` -> `null @0`;
+ load from `b` -> `null @1`;
+ equality equals `null @0` and `null @1` -> `boolean true`;
+ store `boolean true` to `c`
+<5> allocate `Object` instance -> `Object reference`;
+ store `Object reference` to `b`
+<6> load from `a` -> `Object reference`;
+ load from `b` -> `null`;
+ call `equals` on `Object reference` with arguments (`null`)
+ -> `boolean false`;
+ store `boolean false` to `c`
++
+* Equality equals with the `def` type.
++
+[source, Painless]
+----
+<1> def a = 0;
+<2> def b = 1;
+<3> boolean c = a == b;
+<4> def d = new HashMap();
+<5> def e = new ArrayList();
+<6> c = d == e;
+----
++
+<1> declare `def a`;
+ implicit cast `int 0` to `def` -> `def`;
+ store `def` to `a`;
+<2> declare `def b`;
+ implicit cast `int 1` to `def` -> `def`;
+ store `def` to `b`;
+<3> declare `boolean c`;
+ load from `a` -> `def`;
+ implicit cast `a` to `int 0` -> `int 0`;
+ load from `b` -> `def`;
+ implicit cast `b` to `int 1` -> `int 1`;
+ equality equals `int 0` and `int 1` -> `boolean false`;
+ store `boolean false` to `c`
+<4> declare `def d`;
+ allocate `HashMap` instance -> `HashMap reference`;
+ implicit cast `HashMap reference` to `def` -> `def`
+ store `def` to `d`;
+<5> declare `def e`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `def` -> `def`
+ store `def` to `d`;
+<6> load from `d` -> `def`;
+ implicit cast `def` to `HashMap reference` -> `HashMap reference`;
+ load from `e` -> `def`;
+ implicit cast `def` to `ArrayList reference` -> `ArrayList reference`;
+ call `equals` on `HashMap reference` with arguments (`ArrayList reference`)
+ -> `boolean false`;
+ store `boolean false` to `c`
+
+[[equality-not-equals-operator]]
+==== Equality Not Equals
+
+Use the `equality not equals operator '!='` to COMPARE two values where a
+resultant `boolean` type value is `true` if the two values are NOT equal and
+`false` otherwise. The member method, `equals`, is implicitly called when the
+values are reference type values where the first value is the target of the call
+and the second value is the argument with the resultant `boolean` type value
+flipped. This operation is `null-safe` where if both values are `null` the
+resultant `boolean` type value is `false`, and if only one value is `null` the
+resultant `boolean` type value is `true`. A valid comparison is between boolean
+type values, numeric type values, or reference type values.
+
+*Errors*
+
+* If a comparison is made between a `boolean` type value and numeric type value.
+* If a comparison is made between a primitive type value and a reference type
+ value.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+equality_not_equals: expression '!=' expression;
+----
+
+*Promotion*
+
+[cols="<1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1"]
+|====
+| | boolean | byte | short | char | int | long | float | double | Reference | def
+| boolean | boolean | - | - | - | - | - | - | - | - | def
+| byte | - | int | int | int | int | long | float | double | - | def
+| short | - | int | int | int | int | long | float | double | - | def
+| char | - | int | int | int | int | long | float | double | - | def
+| int | - | int | int | int | int | long | float | double | - | def
+| long | - | long | long | long | long | long | float | double | - | def
+| float | - | float | float | float | float | float | float | double | - | def
+| double | - | double | double | double | double | double | double | double | - | def
+| Reference | - | - | - | - | - | - | - | - | Object | def
+| def | def | def | def | def | def | def | def | def | def | def
+|====
+
+*Examples*
+
+* Equality not equals with the `boolean` type.
++
+[source,Painless]
+----
+<1> boolean a = true;
+<2> boolean b = false;
+<3> a = a != false;
+<4> b = a != b;
+----
++
+<1> declare `boolean a`;
+ store `boolean true` to `a`
+<2> declare `boolean b`;
+ store `boolean false` to `b`
+<3> load from `a` -> `boolean true`;
+ equality not equals `boolean true` and `boolean false` -> `boolean true`;
+ store `boolean true` to `a`
+<4> load from `a` -> `boolean true`;
+ load from `b` -> `boolean false`;
+ equality not equals `boolean true` and `boolean false` -> `boolean true`;
+ store `boolean true` to `b`
++
+* Equality not equals with primitive types.
++
+[source,Painless]
+----
+<1> int a = 1;
+<2> double b = 2.0;
+<3> boolean c = a != b;
+<4> c = 1 != a;
+----
++
+<1> declare `int a`;
+ store `int 1` to `a`
+<2> declare `double b`;
+ store `double 1.0` to `b`
+<3> declare `boolean c`;
+ load from `a` -> `int 1`;
+ load from `b` -> `double 2.0`;
+ promote `int 1` and `double 2.0`: result `double`;
+ implicit cast `int 1` to `double 1.0` -> `double `1.0`;
+ equality not equals `double 1.0` and `double 2.0` -> `boolean true`;
+ store `boolean true` to `c`
+<4> load from `a` -> `int 1 @1`;
+ equality not equals `int 1 @0` and `int 1 @1` -> `boolean false`;
+ store `boolean false` to `c`
++
+* Equality not equals with reference types.
++
+[source,Painless]
+----
+<1> List a = new ArrayList();
+<2> List b = new ArrayList();
+<3> a.add(1);
+<4> boolean c = a == b;
+<5> b.add(1);
+<6> c = a == b;
+----
++
+<1> declare `List a`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `List reference` -> `List reference`;
+ store `List reference` to `a`
+<2> declare `List b`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `List reference` -> `List reference`;
+ store `List reference` to `b`
+<3> load from `a` -> `List reference`;
+ call `add` on `List reference` with arguments (`int 1)`
+<4> declare `boolean c`;
+ load from `a` -> `List reference @0`;
+ load from `b` -> `List reference @1`;
+ call `equals` on `List reference @0` with arguments (`List reference @1`)
+ -> `boolean false`;
+ boolean not `boolean false` -> `boolean true`
+ store `boolean true` to `c`
+<5> load from `b` -> `List reference`;
+ call `add` on `List reference` with arguments (`int 1`)
+<6> load from `a` -> `List reference @0`;
+ load from `b` -> `List reference @1`;
+ call `equals` on `List reference @0` with arguments (`List reference @1`)
+ -> `boolean true`;
+ boolean not `boolean true` -> `boolean false`;
+ store `boolean false` to `c`
++
+* Equality not equals with `null`.
++
+[source,Painless]
+----
+<1> Object a = null;
+<2> Object b = null;
+<3> boolean c = a == null;
+<4> c = a == b;
+<5> b = new Object();
+<6> c = a == b;
+----
++
+<1> declare `Object a`;
+ store `null` to `a`
+<2> declare `Object b`;
+ store `null` to `b`
+<3> declare `boolean c`;
+ load from `a` -> `null @0`;
+ equality not equals `null @0` and `null @1` -> `boolean false`;
+ store `boolean false` to `c`
+<4> load from `a` -> `null @0`;
+ load from `b` -> `null @1`;
+ equality not equals `null @0` and `null @1` -> `boolean false`;
+ store `boolean false` to `c`
+<5> allocate `Object` instance -> `Object reference`;
+ store `Object reference` to `b`
+<6> load from `a` -> `Object reference`;
+ load from `b` -> `null`;
+ call `equals` on `Object reference` with arguments (`null`)
+ -> `boolean false`;
+ boolean not `boolean false` -> `boolean true`;
+ store `boolean true` to `c`
++
+* Equality not equals with the `def` type.
++
+[source, Painless]
+----
+<1> def a = 0;
+<2> def b = 1;
+<3> boolean c = a == b;
+<4> def d = new HashMap();
+<5> def e = new ArrayList();
+<6> c = d == e;
+----
++
+<1> declare `def a`;
+ implicit cast `int 0` to `def` -> `def`;
+ store `def` to `a`;
+<2> declare `def b`;
+ implicit cast `int 1` to `def` -> `def`;
+ store `def` to `b`;
+<3> declare `boolean c`;
+ load from `a` -> `def`;
+ implicit cast `a` to `int 0` -> `int 0`;
+ load from `b` -> `def`;
+ implicit cast `b` to `int 1` -> `int 1`;
+ equality equals `int 0` and `int 1` -> `boolean false`;
+ store `boolean false` to `c`
+<4> declare `def d`;
+ allocate `HashMap` instance -> `HashMap reference`;
+ implicit cast `HashMap reference` to `def` -> `def`
+ store `def` to `d`;
+<5> declare `def e`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `def` -> `def`
+ store `def` to `d`;
+<6> load from `d` -> `def`;
+ implicit cast `def` to `HashMap reference` -> `HashMap reference`;
+ load from `e` -> `def`;
+ implicit cast `def` to `ArrayList reference` -> `ArrayList reference`;
+ call `equals` on `HashMap reference` with arguments (`ArrayList reference`)
+ -> `boolean false`;
+ store `boolean false` to `c`
+
+[[identity-equals-operator]]
+==== Identity Equals
+
+Use the `identity equals operator '==='` to COMPARE two values where a resultant
+`boolean` type value is `true` if the two values are equal and `false`
+otherwise. A reference type value is equal to another reference type value if
+both values refer to same instance on the heap or if both values are `null`. A
+valid comparison is between `boolean` type values, numeric type values, or
+reference type values.
+
+*Errors*
+
+* If a comparison is made between a `boolean` type value and numeric type value.
+* If a comparison is made between a primitive type value and a reference type
+ value.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+identity_equals: expression '===' expression;
+----
+
+*Promotion*
+
+[cols="<1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1"]
+|====
+| | boolean | byte | short | char | int | long | float | double | Reference | def
+| boolean | boolean | - | - | - | - | - | - | - | - | def
+| byte | - | int | int | int | int | long | float | double | - | def
+| short | - | int | int | int | int | long | float | double | - | def
+| char | - | int | int | int | int | long | float | double | - | def
+| int | - | int | int | int | int | long | float | double | - | def
+| long | - | long | long | long | long | long | float | double | - | def
+| float | - | float | float | float | float | float | float | double | - | def
+| double | - | double | double | double | double | double | double | double | - | def
+| Reference | - | - | - | - | - | - | - | - | Object | def
+| def | def | def | def | def | def | def | def | def | def | def
+|====
+
+*Examples*
+
+* Identity equals with reference types.
++
+[source,Painless]
+----
+<1> List a = new ArrayList();
+<2> List b = new ArrayList();
+<3> List c = a;
+<4> boolean c = a === b;
+<5> c = a === c;
+----
++
+<1> declare `List a`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `List reference` -> `List reference`;
+ store `List reference` to `a`
+<2> declare `List b`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `List reference` -> `List reference`;
+ store `List reference` to `b`
+<3> load from `a` -> `List reference`;
+ store `List reference` to `c`
+<4> declare `boolean c`;
+ load from `a` -> `List reference @0`;
+ load from `b` -> `List reference @1`;
+ identity equals `List reference @0` and `List reference @1`
+ -> `boolean false`
+ store `boolean false` to `c`
+<5> load from `a` -> `List reference @0`;
+ load from `c` -> `List reference @1`;
+ identity equals `List reference @0` and `List reference @1`
+ -> `boolean true`
+ store `boolean true` to `c`
+ (note `List reference @0` and `List reference @1` refer to the same
+ instance)
++
+* Identity equals with `null`.
++
+[source,Painless]
+----
+<1> Object a = null;
+<2> Object b = null;
+<3> boolean c = a === null;
+<4> c = a === b;
+<5> b = new Object();
+<6> c = a === b;
+----
++
+<1> declare `Object a`;
+ store `null` to `a`
+<2> declare `Object b`;
+ store `null` to `b`
+<3> declare `boolean c`;
+ load from `a` -> `null @0`;
+ identity equals `null @0` and `null @1` -> `boolean true`;
+ store `boolean true` to `c`
+<4> load from `a` -> `null @0`;
+ load from `b` -> `null @1`;
+ identity equals `null @0` and `null @1` -> `boolean true`;
+ store `boolean true` to `c`
+<5> allocate `Object` instance -> `Object reference`;
+ store `Object reference` to `b`
+<6> load from `a` -> `Object reference`;
+ load from `b` -> `null`;
+ identity equals `Object reference` and `null` -> `boolean false`;
+ store `boolean false` to `c`
++
+* Identity equals with the `def` type.
++
+[source, Painless]
+----
+<1> def a = new HashMap();
+<2> def b = new ArrayList();
+<3> boolean c = a === b;
+<4> b = a;
+<5> c = a === b;
+----
++
+<1> declare `def d`;
+ allocate `HashMap` instance -> `HashMap reference`;
+ implicit cast `HashMap reference` to `def` -> `def`
+ store `def` to `d`
+<2> declare `def e`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `def` -> `def`
+ store `def` to `d`
+<3> declare `boolean c`;
+ load from `a` -> `def`;
+ implicit cast `def` to `HashMap reference` -> `HashMap reference`;
+ load from `b` -> `def`;
+ implicit cast `def` to `ArrayList reference` -> `ArrayList reference`;
+ identity equals `HashMap reference` and `ArrayList reference`
+ -> `boolean false`;
+ store `boolean false` to `c`
+<4> load from `a` -> `def`;
+ store `def` to `b`
+<5> load from `a` -> `def`;
+ implicit cast `def` to `HashMap reference @0` -> `HashMap reference @0`;
+ load from `b` -> `def`;
+ implicit cast `def` to `HashMap reference @1` -> `HashMap reference @1`;
+ identity equals `HashMap reference @0` and `HashMap reference @1`
+ -> `boolean true`;
+ store `boolean true` to `b`;
+ (note `HashMap reference @0` and `HashMap reference @1` refer to the same
+ instance)
+
+[[identity-not-equals-operator]]
+==== Identity Not Equals
+
+Use the `identity not equals operator '!=='` to COMPARE two values where a
+resultant `boolean` type value is `true` if the two values are NOT equal and
+`false` otherwise. A reference type value is not equal to another reference type
+value if both values refer to different instances on the heap or if one value is
+`null` and the other is not. A valid comparison is between `boolean` type
+values, numeric type values, or reference type values.
+
+*Errors*
+
+* If a comparison is made between a `boolean` type value and numeric type value.
+* If a comparison is made between a primitive type value and a reference type
+ value.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+identity_not_equals: expression '!==' expression;
+----
+
+*Promotion*
+
+[cols="<1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1"]
+|====
+| | boolean | byte | short | char | int | long | float | double | Reference | def
+| boolean | boolean | - | - | - | - | - | - | - | - | def
+| byte | - | int | int | int | int | long | float | double | - | def
+| short | - | int | int | int | int | long | float | double | - | def
+| char | - | int | int | int | int | long | float | double | - | def
+| int | - | int | int | int | int | long | float | double | - | def
+| long | - | long | long | long | long | long | float | double | - | def
+| float | - | float | float | float | float | float | float | double | - | def
+| double | - | double | double | double | double | double | double | double | - | def
+| Reference | - | - | - | - | - | - | - | - | Object | def
+| def | def | def | def | def | def | def | def | def | def | def
+|====
+
+*Examples*
+
+* Identity not equals with reference type values.
++
+[source,Painless]
+----
+<1> List a = new ArrayList();
+<2> List b = new ArrayList();
+<3> List c = a;
+<4> boolean c = a !== b;
+<5> c = a !== c;
+----
++
+<1> declare `List a`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `List reference` -> `List reference`;
+ store `List reference` to `a`
+<2> declare `List b`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `List reference` -> `List reference`;
+ store `List reference` to `b`
+<3> load from `a` -> `List reference`;
+ store `List reference` to `c`
+<4> declare `boolean c`;
+ load from `a` -> `List reference @0`;
+ load from `b` -> `List reference @1`;
+ identity not equals `List reference @0` and `List reference @1`
+ -> `boolean true`
+ store `boolean true` to `c`
+<5> load from `a` -> `List reference @0`;
+ load from `c` -> `List reference @1`;
+ identity not equals `List reference @0` and `List reference @1`
+ -> `boolean false`
+ store `boolean false` to `c`
+ (note `List reference @0` and `List reference @1` refer to the same
+ instance)
++
+* Identity not equals with `null`.
++
+[source,Painless]
+----
+<1> Object a = null;
+<2> Object b = null;
+<3> boolean c = a !== null;
+<4> c = a !== b;
+<5> b = new Object();
+<6> c = a !== b;
+----
++
+<1> declare `Object a`;
+ store `null` to `a`
+<2> declare `Object b`;
+ store `null` to `b`
+<3> declare `boolean c`;
+ load from `a` -> `null @0`;
+ identity not equals `null @0` and `null @1` -> `boolean false`;
+ store `boolean false` to `c`
+<4> load from `a` -> `null @0`;
+ load from `b` -> `null @1`;
+ identity not equals `null @0` and `null @1` -> `boolean false`;
+ store `boolean false` to `c`
+<5> allocate `Object` instance -> `Object reference`;
+ store `Object reference` to `b`
+<6> load from `a` -> `Object reference`;
+ load from `b` -> `null`;
+ identity not equals `Object reference` and `null` -> `boolean true`;
+ store `boolean true` to `c`
++
+* Identity not equals with the `def` type.
++
+[source, Painless]
+----
+<1> def a = new HashMap();
+<2> def b = new ArrayList();
+<3> boolean c = a !== b;
+<4> b = a;
+<5> c = a !== b;
+----
++
+<1> declare `def d`;
+ allocate `HashMap` instance -> `HashMap reference`;
+ implicit cast `HashMap reference` to `def` -> `def`
+ store `def` to `d`
+<2> declare `def e`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `def` -> `def`
+ store `def` to `d`
+<3> declare `boolean c`;
+ load from `a` -> `def`;
+ implicit cast `def` to `HashMap reference` -> `HashMap reference`;
+ load from `b` -> `def`;
+ implicit cast `def` to `ArrayList reference` -> `ArrayList reference`;
+ identity not equals `HashMap reference` and `ArrayList reference`
+ -> `boolean true`;
+ store `boolean true` to `c`
+<4> load from `a` -> `def`;
+ store `def` to `b`
+<5> load from `a` -> `def`;
+ implicit cast `def` to `HashMap reference @0` -> `HashMap reference @0`;
+ load from `b` -> `def`;
+ implicit cast `def` to `HashMap reference @1` -> `HashMap reference @1`;
+ identity not equals `HashMap reference @0` and `HashMap reference @1`
+ -> `boolean false`;
+ store `boolean false` to `b`;
+ (note `HashMap reference @0` and `HashMap reference @1` refer to the same
+ instance)
+
+[[boolean-xor-operator]]
+==== Boolean Xor
+
+Use the `boolean xor operator '^'` to XOR together two `boolean` type values
+where if one `boolean` type value is `true` and the other is `false` the
+resultant `boolean` type value is `true` and `false` otherwise.
+
+*Errors*
+
+* If either evaluated value is a value other than a `boolean` type value or
+ a value that is castable to a `boolean` type value.
+
+*Truth*
+
+[cols="^1,^1,^1"]
+|====
+| | true | false
+| true | false | true
+| false | true | false
+|====
+
+*Grammar*
+
+[source,ANTLR4]
+----
+boolean_xor: expression '^' expression;
+----
+
+*Examples*
+
+* Boolean xor with the `boolean` type.
++
+[source,Painless]
+----
+<1> boolean x = false;
+<2> boolean y = x ^ true;
+<3> y = y ^ x;
+----
++
+<1> declare `boolean x`;
+ store `boolean false` to `x`
+<2> declare `boolean y`;
+ load from `x` -> `boolean false`
+ boolean xor `boolean false` and `boolean true` -> `boolean true`;
+ store `boolean true` to `y`
+<3> load from `y` -> `boolean true @0`;
+ load from `x` -> `boolean true @1`;
+ boolean xor `boolean true @0` and `boolean true @1` -> `boolean false`;
+ store `boolean false` to `y`
++
+* Boolean xor with the `def` type.
++
+[source,Painless]
+----
+<1> def x = false;
+<2> def y = x ^ true;
+<3> y = y ^ x;
+----
++
+<1> declare `def x`;
+ implicit cast `boolean false` to `def` -> `def`;
+ store `def` to `x`
+<2> declare `def y`;
+ load from `x` -> `def`;
+ implicit cast `def` to `boolean false` -> `boolean false`;
+ boolean xor `boolean false` and `boolean true` -> `boolean true`;
+ implicit cast `boolean true` to `def` -> `def`;
+ store `def` to `y`
+<3> load from `y` -> `def`;
+ implicit cast `def` to `boolean true @0` -> `boolean true @0`;
+ load from `x` -> `def`;
+ implicit cast `def` to `boolean true @1` -> `boolean true @1`;
+ boolean xor `boolean true @0` and `boolean true @1` -> `boolean false`;
+ implicit cast `boolean false` -> `def`;
+ store `def` to `y`
+
+[[boolean-and-operator]]
+==== Boolean And
+
+Use the `boolean and operator '&&'` to AND together two `boolean` type values
+where if both `boolean` type values are `true` the resultant `boolean` type
+value is `true` and `false` otherwise.
+
+*Errors*
+
+* If either evaluated value is a value other than a `boolean` type value or
+ a value that is castable to a `boolean` type value.
+
+*Truth*
+
+[cols="^1,^1,^1"]
+|====
+| | true | false
+| true | true | false
+| false | false | false
+|====
+
+*Grammar*
+
+[source,ANTLR4]
+----
+boolean_and: expression '&&' expression;
+----
+
+*Examples*
+
+* Boolean and with the `boolean` type.
++
+[source,Painless]
+----
+<1> boolean x = true;
+<2> boolean y = x && true;
+<3> x = false;
+<4> y = y && x;
+----
++
+<1> declare `boolean x`;
+ store `boolean true` to `x`
+<2> declare `boolean y`;
+ load from `x` -> `boolean true @0`;
+ boolean and `boolean true @0` and `boolean true @1` -> `boolean true`;
+ store `boolean true` to `y`
+<3> store `boolean false` to `x`
+<4> load from `y` -> `boolean true`;
+ load from `x` -> `boolean false`;
+ boolean and `boolean true` and `boolean false` -> `boolean false`;
+ store `boolean false` to `y`
++
+* Boolean and with the `def` type.
++
+[source,Painless]
+----
+<1> def x = true;
+<2> def y = x && true;
+<3> x = false;
+<4> y = y && x;
+----
++
+<1> declare `def x`;
+ implicit cast `boolean true` to `def` -> `def`;
+ store `def` to `x`
+<2> declare `def y`;
+ load from `x` -> `def`;
+ implicit cast `def` to `boolean true @0` -> `boolean true @0`;
+ boolean and `boolean true @0` and `boolean true @1` -> `boolean true`;
+ implicit cast `boolean true` to `def` -> `def`;
+ store `def` to `y`
+<3> implicit cast `boolean false` to `def` -> `def`;
+ store `def` to `x`;
+<4> load from `y` -> `def`;
+ implicit cast `def` to `boolean true` -> `boolean true`;
+ load from `x` -> `def`;
+ implicit cast `def` to `boolean false` -> `boolean false`;
+ boolean and `boolean true` and `boolean false` -> `boolean false`;
+ implicit cast `boolean false` -> `def`;
+ store `def` to `y`
+
+[[boolean-or-operator]]
+==== Boolean Or
+
+Use the `boolean or operator '||'` to OR together two `boolean` type values
+where if either one of the `boolean` type values is `true` the resultant
+`boolean` type value is `true` and `false` otherwise.
+
+*Errors*
+
+* If either evaluated value is a value other than a `boolean` type value or
+ a value that is castable to a `boolean` type value.
+
+*Truth*
+
+[cols="^1,^1,^1"]
+|====
+| | true | false
+| true | true | true
+| false | true | false
+|====
+
+*Grammar:*
+[source,ANTLR4]
+----
+boolean_and: expression '||' expression;
+----
+
+*Examples*
+
+* Boolean or with the `boolean` type.
++
+[source,Painless]
+----
+<1> boolean x = false;
+<2> boolean y = x || true;
+<3> y = false;
+<4> y = y || x;
+----
++
+<1> declare `boolean x`;
+ store `boolean false` to `x`
+<2> declare `boolean y`;
+ load from `x` -> `boolean false`;
+ boolean or `boolean false` and `boolean true` -> `boolean true`;
+ store `boolean true` to `y`
+<3> store `boolean false` to `y`
+<4> load from `y` -> `boolean false @0`;
+ load from `x` -> `boolean false @1`;
+ boolean or `boolean false @0` and `boolean false @1` -> `boolean false`;
+ store `boolean false` to `y`
++
+* Boolean or with the `def` type.
++
+[source,Painless]
+----
+<1> def x = false;
+<2> def y = x || true;
+<3> y = false;
+<4> y = y || x;
+----
++
+<1> declare `def x`;
+ implicit cast `boolean false` to `def` -> `def`;
+ store `def` to `x`
+<2> declare `def y`;
+ load from `x` -> `def`;
+ implicit cast `def` to `boolean false` -> `boolean true`;
+ boolean or `boolean false` and `boolean true` -> `boolean true`;
+ implicit cast `boolean true` to `def` -> `def`;
+ store `def` to `y`
+<3> implicit cast `boolean false` to `def` -> `def`;
+ store `def` to `y`;
+<4> load from `y` -> `def`;
+ implicit cast `def` to `boolean false @0` -> `boolean false @0`;
+ load from `x` -> `def`;
+ implicit cast `def` to `boolean false @1` -> `boolean false @1`;
+ boolean or `boolean false @0` and `boolean false @1` -> `boolean false`;
+ implicit cast `boolean false` -> `def`;
+ store `def` to `y`
diff --git a/docs/painless/painless-operators-general.asciidoc b/docs/painless/painless-operators-general.asciidoc
new file mode 100644
index 00000000000..9bd057432fb
--- /dev/null
+++ b/docs/painless/painless-operators-general.asciidoc
@@ -0,0 +1,432 @@
+[[painless-operators-general]]
+=== Operators: General
+
+[[precedence-operator]]
+==== Precedence
+
+Use the `precedence operator '()'` to guarantee the order of evaluation for an
+expression. An expression encapsulated by the precedence operator (enclosed in
+parentheses) overrides existing precedence relationships between operators and
+is evaluated prior to other expressions in inward-to-outward order.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+precedence: '(' expression ')';
+----
+
+*Examples*
+
+* Precedence with numeric operators.
++
+[source,Painless]
+----
+<1> int x = (5+4)*6;
+<2> int y = 12/(x-50);
+----
++
+<1> declare `int x`;
+ add `int 5` and `int 4` -> `int 9`;
+ multiply `int 9` and `int 6` -> `int 54`;
+ store `int 54` to `x`;
+ (note the add is evaluated before the multiply due to the precedence
+ operator)
+<2> declare `int y`;
+ load from `x` -> `int 54`;
+ subtract `int 50` from `int 54` -> `int 4`;
+ divide `int 12` by `int 4` -> `int 3`;
+ store `int 3` to `y`;
+ (note the subtract is evaluated before the divide due to the precedence
+ operator)
+
+[[function-call-operator]]
+==== Function Call
+
+Use the `function call operator ()` to call an existing function. A
+<> is defined within a script.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+function_call: ID '(' ( expression (',' expression)* )? ')'';
+----
+
+*Examples*
+
+* A function call.
++
+[source,Painless]
+----
+<1> int add(int x, int y) {
+ return x + y;
+ }
+
+<2> int z = add(1, 2);
+----
++
+<1> define function `add` that returns `int` and has parameters (`int x`,
+ `int y`)
+<2> declare `int z`;
+ call `add` with arguments (`int 1`, `int 2`) -> `int 3`;
+ store `int 3` to `z`
+
+[[cast-operator]]
+==== Cast
+
+An explicit cast converts the value of an original type to the equivalent value
+of a target type forcefully as an operation. Use the `cast operator '()'` to
+specify an explicit cast. Refer to <> for more
+information.
+
+[[conditional-operator]]
+==== Conditional
+
+A conditional consists of three expressions. The first expression is evaluated
+with an expected boolean result type. If the first expression evaluates to true
+then the second expression will be evaluated. If the first expression evaluates
+to false then the third expression will be evaluated. The second and third
+expressions will be <> if the evaluated values are not the
+same type. Use the `conditional operator '? :'` as a shortcut to avoid the need
+for a full if/else branch in certain expressions.
+
+*Errors*
+
+* If the first expression does not evaluate to a boolean type value.
+* If the values for the second and third expressions cannot be promoted.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+conditional: expression '?' expression ':' expression;
+----
+
+*Promotion*
+
+[cols="<1,^1,^1,^1,^1,^1,^1,^1,^1,^1"]
+|====
+| | byte | short | char | int | long | float | double | Reference | def
+| byte | int | int | int | int | long | float | double | - | def
+| short | int | int | int | int | long | float | double | - | def
+| char | int | int | int | int | long | float | double | - | def
+| int | int | int | int | int | long | float | double | - | def
+| long | long | long | long | long | long | float | double | - | def
+| float | float | float | float | float | float | float | double | - | def
+| double | double | double | double | double | double | double | double | - | def
+| Reference | - | - | - | - | - | - | - | Object @ | def
+| def | def | def | def | def | def | def | def | def | def
+|====
+
+@ If the two reference type values are the same then this promotion will not
+occur.
+
+*Examples*
+
+* Evaluation of conditionals.
++
+[source,Painless]
+----
+<1> boolean b = true;
+<2> int x = b ? 1 : 2;
+<3> List y = x > 1 ? new ArrayList() : null;
+<4> def z = x < 2 ? x : 2.0;
+----
++
+<1> declare `boolean b`;
+ store `boolean true` to `b`
+<2> declare `int x`;
+ load from `b` -> `boolean true`
+ evaluate 1st expression: `int 1` -> `int 1`;
+ store `int 1` to `x`
+<3> declare `List y`;
+ load from `x` -> `int 1`;
+ `int 1` greater than `int 1` -> `boolean false`;
+ evaluate 2nd expression: `null` -> `null`;
+ store `null` to `y`;
+<4> declare `def z`;
+ load from `x` -> `int 1`;
+ `int 1` less than `int 2` -> `boolean true`;
+ evaluate 1st expression: load from `x` -> `int 1`;
+ promote `int 1` and `double 2.0`: result `double`;
+ implicit cast `int 1` to `double 1.0` -> `double 1.0`;
+ implicit cast `double 1.0` to `def` -> `def`;
+ store `def` to `z`;
+
+[[assignment-operator]]
+==== Assignment
+
+Use the `assignment operator '='` to store a value in a variable or reference
+type member field for use in subsequent operations. Any operation that produces
+a value can be assigned to any variable/field as long as the
+<> are the same or the resultant type can be
+<> to the variable/field type.
+
+See <> for examples using variables.
+
+*Errors*
+
+* If the type of value is unable to match the type of variable or field.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+assignment: field '=' expression
+----
+
+*Examples*
+
+The examples use the following reference type definition:
+
+[source,Painless]
+----
+name:
+ Example
+
+non-static member fields:
+ * int x
+ * def y
+ * List z
+----
+
+* Field assignments of different type values.
++
+[source,Painless]
+----
+<1> Example example = new Example();
+<2> example.x = 1;
+<3> example.y = 2.0;
+<4> example.z = new ArrayList();
+----
++
+<1> declare `Example example`;
+ allocate `Example` instance -> `Example reference`;
+ store `Example reference` to `example`
+<2> load from `example` -> `Example reference`;
+ store `int 1` to `x` of `Example reference`
+<3> load from `example` -> `Example reference`;
+ implicit cast `double 2.0` to `def` -> `def`;
+ store `def` to `y` of `Example reference`
+<4> load from `example` -> `Example reference`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `List reference` -> `List reference`;
+ store `List reference` to `z` of `Example reference`
++
+* A field assignment from a field access.
++
+[source,Painless]
+----
+<1> Example example = new Example();
+<2> example.x = 1;
+<3> example.y = example.x;
+----
++
+<1> declare `Example example`;
+ allocate `Example` instance -> `Example reference`;
+ store `Example reference` to `example`
+<2> load from `example` -> `Example reference`;
+ store `int 1` to `x` of `Example reference`
+<3> load from `example` -> `Example reference @0`;
+ load from `example` -> `Example reference @1`;
+ load from `x` of `Example reference @1` -> `int 1`;
+ implicit cast `int 1` to `def` -> `def`;
+ store `def` to `y` of `Example reference @0`;
+ (note `Example reference @0` and `Example reference @1` are the same)
+
+[[compound-assignment-operator]]
+==== Compound Assignment
+
+Use the `compound assignment operator '$='` as a shortcut for an assignment
+where a binary operation would occur between the variable/field as the
+left-hand side expression and a separate right-hand side expression.
+
+A compound assignment is equivalent to the expression below where V is the
+variable/field and T is the type of variable/member.
+
+[source,Painless]
+----
+V = (T)(V op expression);
+----
+
+*Operators*
+
+The table below shows the available operators for use in a compound assignment.
+Each operator follows the casting/promotion rules according to their regular
+definition. For numeric operations there is an extra implicit cast when
+necessary to return the promoted numeric type value to the original numeric type
+value of the variable/field and can result in data loss.
+
+|====
+|Operator|Compound Symbol
+|Multiplication|*=
+|Division|/=
+|Remainder|%=
+|Addition|+=
+|Subtraction|-=
+|Left Shift|<<=
+|Right Shift|>>=
+|Unsigned Right Shift|>>>=
+|Bitwise And|&=
+|Boolean And|&=
+|Bitwise Xor|^=
+|Boolean Xor|^=
+|Bitwise Or|\|=
+|Boolean Or|\|=
+|String Concatenation|+=
+|====
+
+*Errors*
+
+* If the type of value is unable to match the type of variable or field.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+compound_assignment: ( ID | field ) '$=' expression;
+----
+
+Note the use of the `$=` represents the use of any of the possible binary
+operators.
+
+*Examples*
+
+* Compound assignment for each numeric operator.
++
+[source,Painless]
+----
+<1> int i = 10;
+<2> i *= 2;
+<3> i /= 5;
+<4> i %= 3;
+<5> i += 5;
+<6> i -= 5;
+<7> i <<= 2;
+<8> i >>= 1;
+<9> i >>>= 1;
+<10> i &= 15;
+<11> i ^= 12;
+<12> i |= 2;
+----
++
+<1> declare `int i`;
+ store `int 10` to `i`
+<2> load from `i` -> `int 10`;
+ multiply `int 10` and `int 2` -> `int 20`;
+ store `int 20` to `i`;
+ (note this is equivalent to `i = i*2`)
+<3> load from `i` -> `int 20`;
+ divide `int 20` by `int 5` -> `int 4`;
+ store `int 4` to `i`;
+ (note this is equivalent to `i = i/5`)
+<4> load from `i` -> `int 4`;
+ remainder `int 4` by `int 3` -> `int 1`;
+ store `int 1` to `i`;
+ (note this is equivalent to `i = i%3`)
+<5> load from `i` -> `int 1`;
+ add `int 1` and `int 5` -> `int 6`;
+ store `int 6` to `i`;
+ (note this is equivalent to `i = i+5`)
+<6> load from `i` -> `int 6`;
+ subtract `int 5` from `int 6` -> `int 1`;
+ store `int 1` to `i`;
+ (note this is equivalent to `i = i-5`)
+<7> load from `i` -> `int 1`;
+ left shift `int 1` by `int 2` -> `int 4`;
+ store `int 4` to `i`;
+ (note this is equivalent to `i = i<<2`)
+<8> load from `i` -> `int 4`;
+ right shift `int 4` by `int 1` -> `int 2`;
+ store `int 2` to `i`;
+ (note this is equivalent to `i = i>>1`)
+<9> load from `i` -> `int 2`;
+ unsigned right shift `int 2` by `int 1` -> `int 1`;
+ store `int 1` to `i`;
+ (note this is equivalent to `i = i>>>1`)
+<10> load from `i` -> `int 1`;
+ bitwise and `int 1` and `int 15` -> `int 1`;
+ store `int 1` to `i`;
+ (note this is equivalent to `i = i&2`)
+<11> load from `i` -> `int 1`;
+ bitwise xor `int 1` and `int 12` -> `int 13`;
+ store `int 13` to `i`;
+ (note this is equivalent to `i = i^2`)
+<12> load from `i` -> `int 13`;
+ bitwise or `int 13` and `int 2` -> `int 15`;
+ store `int 15` to `i`;
+ (note this is equivalent to `i = i|2`)
++
+* Compound assignment for each boolean operator.
++
+[source,Painless]
+----
+<1> boolean b = true;
+<2> b &= false;
+<3> b ^= false;
+<4> b |= true;
+----
++
+<1> declare `boolean b`;
+ store `boolean true` in `b`;
+<2> load from `b` -> `boolean true`;
+ boolean and `boolean true` and `boolean false` -> `boolean false`;
+ store `boolean false` to `b`;
+ (note this is equivalent to `b = b && false`)
+<3> load from `b` -> `boolean false`;
+ boolean xor `boolean false` and `boolean false` -> `boolean false`;
+ store `boolean false` to `b`;
+ (note this is equivalent to `b = b ^ false`)
+<4> load from `b` -> `boolean true`;
+ boolean or `boolean false` and `boolean true` -> `boolean true`;
+ store `boolean true` to `b`;
+ (note this is equivalent to `b = b || true`)
++
+* A compound assignment with the string concatenation operator.
++
+[source,Painless]
+----
+<1> String s = 'compound';
+<2> s += ' assignment';
+----
+<1> declare `String s`;
+ store `String 'compound'` to `s`;
+<2> load from `s` -> `String 'compound'`;
+ string concat `String 'compound'` and `String ' assignment''`
+ -> `String 'compound assignment'`;
+ store `String 'compound assignment'` to `s`;
+ (note this is equivalent to `s = s + ' assignment'`)
++
+* A compound assignment with the `def` type.
++
+[source,Painless]
+----
+<1> def x = 1;
+<2> x += 2;
+----
+<1> declare `def x`;
+ implicit cast `int 1` to `def`;
+ store `def` to `x`;
+<2> load from `x` -> `def`;
+ implicit cast `def` to `int 1` -> `int 1`;
+ add `int 1` and `int 2` -> `int 3`;
+ implicit cast `int 3` to `def` -> `def`;
+ store `def` to `x`;
+ (note this is equivalent to `x = x+2`)
++
+* A compound assignment with an extra implicit cast.
++
+[source,Painless]
+----
+<1> byte b = 1;
+<2> b += 2;
+----
+<1> declare `byte b`;
+ store `byte 1` to `x`;
+<2> load from `x` -> `byte 1`;
+ implicit cast `byte 1 to `int 1` -> `int 1`;
+ add `int 1` and `int 2` -> `int 3`;
+ implicit cast `int 3` to `byte 3` -> `byte 3`;
+ store `byte 3` to `b`;
+ (note this is equivalent to `b = b+2`)
diff --git a/docs/painless/painless-operators-numeric.asciidoc b/docs/painless/painless-operators-numeric.asciidoc
new file mode 100644
index 00000000000..d39b895908f
--- /dev/null
+++ b/docs/painless/painless-operators-numeric.asciidoc
@@ -0,0 +1,1339 @@
+[[painless-operators-numeric]]
+=== Operators: Numeric
+
+[[post-increment-operator]]
+==== Post Increment
+
+Use the `post increment operator '++'` to INCREASE the value of a numeric type
+variable/field by `1`. An extra implicit cast is necessary to return the
+promoted numeric type value to the original numeric type value of the
+variable/field for the following types: `byte`, `short`, and `char`. If a
+variable/field is read as part of an expression the value is loaded prior to the
+increment.
+
+*Errors*
+
+* If the variable/field is a non-numeric type.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+post_increment: ( variable | field ) '++';
+----
+
+*Promotion*
+
+[options="header",cols="<1,<1,<1"]
+|====
+| original | promoted | implicit
+| byte | int | byte
+| short | int | short
+| char | int | char
+| int | int |
+| long | long |
+| float | float |
+| double | double |
+| def | def |
+|====
+
+*Examples*
+
+* Post increment with different numeric types.
++
+[source,Painless]
+----
+<1> short i = 0;
+<2> i++;
+<3> long j = 1;
+<4> long k;
+<5> k = j++;
+----
++
+<1> declare `short i`;
+ store `short 0` to `i`
+<2> load from `i` -> `short 0`;
+ promote `short 0`: result `int`;
+ add `int 0` and `int 1` -> `int 1`;
+ implicit cast `int 1` to `short 1`;
+ store `short 1` to `i`
+<3> declare `long j`;
+ implicit cast `int 1` to `long 1` -> `long 1`;
+ store `long 1` to `j`
+<4> declare `long k`;
+ store default `long 0` to `k`
+<5> load from `j` -> `long 1`;
+ store `long 1` to `k`;
+ add `long 1` and `long 1` -> `long 2`;
+ store `long 2` to `j`
++
+* Post increment with the `def` type.
++
+[source,Painless]
+----
+<1> def x = 1;
+<2> x++;
+----
++
+<1> declare `def x`;
+ implicit cast `int 1` to `def` -> `def`;
+ store `def` to `x`
+<2> load from `x` -> `def`;
+ implicit cast `def` to `int 1`;
+ add `int 1` and `int 1` -> `int 2`;
+ implicit cast `int 2` to `def`;
+ store `def` to `x`
+
+[[post-decrement-operator]]
+==== Post Decrement
+
+Use the `post decrement operator '--'` to DECREASE the value of a numeric type
+variable/field by `1`. An extra implicit cast is necessary to return the
+promoted numeric type value to the original numeric type value of the
+variable/field for the following types: `byte`, `short`, and `char`. If a
+variable/field is read as part of an expression the value is loaded prior to
+the decrement.
+
+*Errors*
+
+* If the variable/field is a non-numeric type.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+post_decrement: ( variable | field ) '--';
+----
+
+*Promotion*
+
+[options="header",cols="<1,<1,<1"]
+|====
+| original | promoted | implicit
+| byte | int | byte
+| short | int | short
+| char | int | char
+| int | int |
+| long | long |
+| float | float |
+| double | double |
+| def | def |
+|====
+
+*Examples*
+
+* Post decrement with different numeric types.
++
+[source,Painless]
+----
+<1> short i = 0;
+<2> i--;
+<3> long j = 1;
+<4> long k;
+<5> k = j--;
+----
++
+<1> declare `short i`;
+ store `short 0` to `i`
+<2> load from `i` -> `short 0`;
+ promote `short 0`: result `int`;
+ subtract `int 1` from `int 0` -> `int -1`;
+ implicit cast `int -1` to `short -1`;
+ store `short -1` to `i`
+<3> declare `long j`;
+ implicit cast `int 1` to `long 1` -> `long 1`;
+ store `long 1` to `j`
+<4> declare `long k`;
+ store default `long 0` to `k`
+<5> load from `j` -> `long 1`;
+ store `long 1` to `k`;
+ subtract `long 1` from `long 1` -> `long 0`;
+ store `long 0` to `j`
++
+* Post decrement with the `def` type.
++
+[source,Painless]
+----
+<1> def x = 1;
+<2> x--;
+----
++
+<1> declare `def x`;
+ implicit cast `int 1` to `def` -> `def`;
+ store `def` to `x`
+<2> load from `x` -> `def`;
+ implicit cast `def` to `int 1`;
+ subtract `int 1` from `int 1` -> `int 0`;
+ implicit cast `int 0` to `def`;
+ store `def` to `x`
+
+[[pre-increment-operator]]
+==== Pre Increment
+
+Use the `pre increment operator '++'` to INCREASE the value of a numeric type
+variable/field by `1`. An extra implicit cast is necessary to return the
+promoted numeric type value to the original numeric type value of the
+variable/field for the following types: `byte`, `short`, and `char`. If a
+variable/field is read as part of an expression the value is loaded after the
+increment.
+
+*Errors*
+
+* If the variable/field is a non-numeric type.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+pre_increment: '++' ( variable | field );
+----
+
+*Promotion*
+
+[options="header",cols="<1,<1,<1"]
+|====
+| original | promoted | implicit
+| byte | int | byte
+| short | int | short
+| char | int | char
+| int | int |
+| long | long |
+| float | float |
+| double | double |
+| def | def |
+|====
+
+*Examples*
+
+* Pre increment with different numeric types.
++
+[source,Painless]
+----
+<1> short i = 0;
+<2> ++i;
+<3> long j = 1;
+<4> long k;
+<5> k = ++j;
+----
++
+<1> declare `short i`;
+ store `short 0` to `i`
+<2> load from `i` -> `short 0`;
+ promote `short 0`: result `int`;
+ add `int 0` and `int 1` -> `int 1`;
+ implicit cast `int 1` to `short 1`;
+ store `short 1` to `i`
+<3> declare `long j`;
+ implicit cast `int 1` to `long 1` -> `long 1`;
+ store `long 1` to `j`
+<4> declare `long k`;
+ store default `long 0` to `k`
+<5> load from `j` -> `long 1`;
+ add `long 1` and `long 1` -> `long 2`;
+ store `long 2` to `j`;
+ store `long 2` to `k`
++
+* Pre increment with the `def` type.
++
+[source,Painless]
+----
+<1> def x = 1;
+<2> ++x;
+----
++
+<1> declare `def x`;
+ implicit cast `int 1` to `def` -> `def`;
+ store `def` to `x`
+<2> load from `x` -> `def`;
+ implicit cast `def` to `int 1`;
+ add `int 1` and `int 1` -> `int 2`;
+ implicit cast `int 2` to `def`;
+ store `def` to `x`
+
+[[pre-decrement-operator]]
+==== Pre Decrement
+
+Use the `pre decrement operator '--'` to DECREASE the value of a numeric type
+variable/field by `1`. An extra implicit cast is necessary to return the
+promoted numeric type value to the original numeric type value of the
+variable/field for the following types: `byte`, `short`, and `char`. If a
+variable/field is read as part of an expression the value is loaded after the
+decrement.
+
+*Errors*
+
+* If the variable/field is a non-numeric type.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+pre_increment: '--' ( variable | field );
+----
+
+*Promotion*
+
+[options="header",cols="<1,<1,<1"]
+|====
+| original | promoted | implicit
+| byte | int | byte
+| short | int | short
+| char | int | char
+| int | int |
+| long | long |
+| float | float |
+| double | double |
+| def | def |
+|====
+
+*Examples*
+
+* Pre decrement with different numeric types.
++
+[source,Painless]
+----
+<1> short i = 0;
+<2> --i;
+<3> long j = 1;
+<4> long k;
+<5> k = --j;
+----
++
+<1> declare `short i`;
+ store `short 0` to `i`
+<2> load from `i` -> `short 0`;
+ promote `short 0`: result `int`;
+ subtract `int 1` from `int 0` -> `int -1`;
+ implicit cast `int -1` to `short -1`;
+ store `short -1` to `i`
+<3> declare `long j`;
+ implicit cast `int 1` to `long 1` -> `long 1`;
+ store `long 1` to `j`
+<4> declare `long k`;
+ store default `long 0` to `k`
+<5> load from `j` -> `long 1`;
+ subtract `long 1` from `long 1` -> `long 0`;
+ store `long 0` to `j`
+ store `long 0` to `k`;
++
+* Pre decrement operator with the `def` type.
++
+[source,Painless]
+----
+<1> def x = 1;
+<2> --x;
+----
++
+<1> declare `def x`;
+ implicit cast `int 1` to `def` -> `def`;
+ store `def` to `x`
+<2> load from `x` -> `def`;
+ implicit cast `def` to `int 1`;
+ subtract `int 1` from `int 1` -> `int 0`;
+ implicit cast `int 0` to `def`;
+ store `def` to `x`
+
+[[unary-positive-operator]]
+==== Unary Positive
+
+Use the `unary positive operator '+'` to the preserve the IDENTITY of a
+numeric type value.
+
+*Errors*
+
+* If the value is a non-numeric type.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+unary_positive: '+' expression;
+----
+
+*Examples*
+
+* Unary positive with different numeric types.
++
+[source,Painless]
+----
+<1> int x = +1;
+<2> long y = +x;
+----
++
+<1> declare `int x`;
+ identity `int 1` -> `int 1`;
+ store `int 1` to `x`
+<2> declare `long y`;
+ load from `x` -> `int 1`;
+ identity `int 1` -> `int 1`;
+ implicit cast `int 1` to `long 1` -> `long 1`;
+ store `long 1` to `y`
++
+* Unary positive with the `def` type.
++
+[source,Painless]
+----
+<1> def z = +1;
+<2> int i = +z;
+----
+<1> declare `def z`;
+ identity `int 1` -> `int 1`;
+ implicit cast `int 1` to `def`;
+ store `def` to `z`
+<2> declare `int i`;
+ load from `z` -> `def`;
+ implicit cast `def` to `int 1`;
+ identity `int 1` -> `int 1`;
+ store `int 1` to `i`;
+
+[[unary-negative-operator]]
+==== Unary Negative
+
+Use the `unary negative operator '-'` to NEGATE a numeric type value.
+
+*Errors*
+
+* If the value is a non-numeric type.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+unary_negative: '-' expression;
+----
+
+*Examples*
+
+* Unary negative with different numeric types.
++
+[source,Painless]
+----
+<1> int x = -1;
+<2> long y = -x;
+----
++
+<1> declare `int x`;
+ negate `int 1` -> `int -1`;
+ store `int -1` to `x`
+<2> declare `long y`;
+ load from `x` -> `int 1`;
+ negate `int -1` -> `int 1`;
+ implicit cast `int 1` to `long 1` -> `long 1`;
+ store `long 1` to `y`
++
+* Unary negative with the `def` type.
++
+[source,Painless]
+----
+<1> def z = -1;
+<2> int i = -z;
+----
+<1> declare `def z`;
+ negate `int 1` -> `int -1`;
+ implicit cast `int -1` to `def`;
+ store `def` to `z`
+<2> declare `int i`;
+ load from `z` -> `def`;
+ implicit cast `def` to `int -1`;
+ negate `int -1` -> `int 1`;
+ store `int 1` to `i`;
+
+[[bitwise-not-operator]]
+==== Bitwise Not
+
+Use the `bitwise not operator '~'` to NOT each bit in an integer type value
+where a `1-bit` is flipped to a resultant `0-bit` and a `0-bit` is flipped to a
+resultant `1-bit`.
+
+*Errors*
+
+* If the value is a non-integer type.
+
+*Bits*
+
+[options="header",cols="<1,<1"]
+|====
+| original | result
+| 1 | 0
+| 0 | 1
+|====
+
+*Grammar*
+
+[source,ANTLR4]
+----
+bitwise_not: '~' expression;
+----
+
+*Promotion*
+
+[options="header",cols="<1,<1"]
+|====
+| original | promoted
+| byte | int
+| short | int
+| char | int
+| int | int
+| long | long
+| def | def
+|====
+
+*Examples*
+
+* Bitwise not with different numeric types.
++
+[source,Painless]
+----
+<1> byte b = 1;
+<2> int i = ~b;
+<3> long l = ~i;
+----
++
+<1> declare `byte x`;
+ store `byte 1` to b
+<2> declare `int i`;
+ load from `b` -> `byte 1`;
+ implicit cast `byte 1` to `int 1` -> `int 1`;
+ bitwise not `int 1` -> `int -2`;
+ store `int -2` to `i`
+<3> declare `long l`;
+ load from `i` -> `int -2`;
+ implicit cast `int -2` to `long -2` -> `long -2`;
+ bitwise not `long -2` -> `long 1`;
+ store `long 1` to `l`
++
+* Bitwise not with the `def` type.
++
+[source,Painless]
+----
+<1> def d = 1;
+<2> def e = ~d;
+----
++
+<1> declare `def d`;
+ implicit cast `int 1` to `def` -> `def`;
+ store `def` to `d`;
+<2> declare `def e`;
+ load from `d` -> `def`;
+ implicit cast `def` to `int 1` -> `int 1`;
+ bitwise not `int 1` -> `int -2`;
+ implicit cast `int 1` to `def` -> `def`;
+ store `def` to `e`
+
+[[multiplication-operator]]
+==== Multiplication
+
+Use the `multiplication operator '*'` to MULTIPLY together two numeric type
+values. Rules for resultant overflow and NaN values follow the JVM
+specification.
+
+*Errors*
+
+* If either of the values is a non-numeric type.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+multiplication: expression '*' expression;
+----
+
+*Promotion*
+
+[cols="<1,^1,^1,^1,^1,^1,^1,^1,^1"]
+|====
+| | byte | short | char | int | long | float | double | def
+| byte | int | int | int | int | long | float | double | def
+| short | int | int | int | int | long | float | double | def
+| char | int | int | int | int | long | float | double | def
+| int | int | int | int | int | long | float | double | def
+| long | long | long | long | long | long | float | double | def
+| float | float | float | float | float | float | float | double | def
+| double | double | double | double | double | double | double | double | def
+| def | def | def | def | def | def | def | def | def
+|====
+
+*Examples*
+
+* Multiplication with different numeric types.
++
+[source,Painless]
+----
+<1> int i = 5*4;
+<2> double d = i*7.0;
+----
++
+<1> declare `int i`;
+ multiply `int 4` by `int 5` -> `int 20`;
+ store `int 20` in `i`
+<2> declare `double d`;
+ load from `int i` -> `int 20`;
+ promote `int 20` and `double 7.0`: result `double`;
+ implicit cast `int 20` to `double 20.0` -> `double 20.0`;
+ multiply `double 20.0` by `double 7.0` -> `double 140.0`;
+ store `double 140.0` to `d`
++
+* Multiplication with the `def` type.
++
+[source,Painless]
+----
+<1> def x = 5*4;
+<2> def y = x*2;
+----
+<1> declare `def x`;
+ multiply `int 5` by `int 4` -> `int 20`;
+ implicit cast `int 20` to `def` -> `def`;
+ store `def` in `x`
+<2> declare `def y`;
+ load from `x` -> `def`;
+ implicit cast `def` to `int 20`;
+ multiply `int 20` by `int 2` -> `int 40`;
+ implicit cast `int 40` to `def` -> `def`;
+ store `def` to `y`
+
+[[division-operator]]
+==== Division
+
+Use the `division operator '/'` to DIVIDE one numeric type value by another.
+Rules for NaN values and division by zero follow the JVM specification. Division
+with integer values drops the remainder of the resultant value.
+
+*Errors*
+
+* If either of the values is a non-numeric type.
+* If a left-hand side integer type value is divided by a right-hand side integer
+ type value of `0`.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+division: expression '/' expression;
+----
+
+*Promotion*
+
+[cols="<1,^1,^1,^1,^1,^1,^1,^1,^1"]
+|====
+| | byte | short | char | int | long | float | double | def
+| byte | int | int | int | int | long | float | double | def
+| short | int | int | int | int | long | float | double | def
+| char | int | int | int | int | long | float | double | def
+| int | int | int | int | int | long | float | double | def
+| long | long | long | long | long | long | float | double | def
+| float | float | float | float | float | float | float | double | def
+| double | double | double | double | double | double | double | double | def
+| def | def | def | def | def | def | def | def | def
+|====
+
+*Examples*
+
+* Division with different numeric types.
++
+[source,Painless]
+----
+<1> int i = 29/4;
+<2> double d = i/7.0;
+----
++
+<1> declare `int i`;
+ divide `int 29` by `int 4` -> `int 7`;
+ store `int 7` in `i`
+<2> declare `double d`;
+ load from `int i` -> `int 7`;
+ promote `int 7` and `double 7.0`: result `double`;
+ implicit cast `int 7` to `double 7.0` -> `double 7.0`;
+ divide `double 7.0` by `double 7.0` -> `double 1.0`;
+ store `double 1.0` to `d`
++
+* Division with the `def` type.
++
+[source,Painless]
+----
+<1> def x = 5/4;
+<2> def y = x/2;
+----
+<1> declare `def x`;
+ divide `int 5` by `int 4` -> `int 1`;
+ implicit cast `int 1` to `def` -> `def`;
+ store `def` in `x`
+<2> declare `def y`;
+ load from `x` -> `def`;
+ implicit cast `def` to `int 1`;
+ divide `int 1` by `int 2` -> `int 0`;
+ implicit cast `int 0` to `def` -> `def`;
+ store `def` to `y`
+
+[[remainder-operator]]
+==== Remainder
+
+Use the `remainder operator '%'` to calculate the REMAINDER for division
+between two numeric type values. Rules for NaN values and division by zero follow the JVM
+specification.
+
+*Errors*
+
+* If either of the values is a non-numeric type.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+remainder: expression '%' expression;
+----
+
+*Promotion*
+
+[cols="<1,^1,^1,^1,^1,^1,^1,^1,^1"]
+|====
+| | byte | short | char | int | long | float | double | def
+| byte | int | int | int | int | long | float | double | def
+| short | int | int | int | int | long | float | double | def
+| char | int | int | int | int | long | float | double | def
+| int | int | int | int | int | long | float | double | def
+| long | long | long | long | long | long | float | double | def
+| float | float | float | float | float | float | float | double | def
+| double | double | double | double | double | double | double | double | def
+| def | def | def | def | def | def | def | def | def
+|====
+
+*Examples*
+
+* Remainder with different numeric types.
++
+[source,Painless]
+----
+<1> int i = 29%4;
+<2> double d = i%7.0;
+----
++
+<1> declare `int i`;
+ remainder `int 29` by `int 4` -> `int 1`;
+ store `int 7` in `i`
+<2> declare `double d`;
+ load from `int i` -> `int 1`;
+ promote `int 1` and `double 7.0`: result `double`;
+ implicit cast `int 1` to `double 1.0` -> `double 1.0`;
+ remainder `double 1.0` by `double 7.0` -> `double 1.0`;
+ store `double 1.0` to `d`
++
+* Remainder with the `def` type.
++
+[source,Painless]
+----
+<1> def x = 5%4;
+<2> def y = x%2;
+----
+<1> declare `def x`;
+ remainder `int 5` by `int 4` -> `int 1`;
+ implicit cast `int 1` to `def` -> `def`;
+ store `def` in `x`
+<2> declare `def y`;
+ load from `x` -> `def`;
+ implicit cast `def` to `int 1`;
+ remainder `int 1` by `int 2` -> `int 1`;
+ implicit cast `int 1` to `def` -> `def`;
+ store `def` to `y`
+
+[[addition-operator]]
+==== Addition
+
+Use the `addition operator '+'` to ADD together two numeric type values. Rules
+for resultant overflow and NaN values follow the JVM specification.
+
+*Errors*
+
+* If either of the values is a non-numeric type.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+addition: expression '+' expression;
+----
+
+*Promotion*
+
+[cols="<1,^1,^1,^1,^1,^1,^1,^1,^1"]
+|====
+| | byte | short | char | int | long | float | double | def
+| byte | int | int | int | int | long | float | double | def
+| short | int | int | int | int | long | float | double | def
+| char | int | int | int | int | long | float | double | def
+| int | int | int | int | int | long | float | double | def
+| long | long | long | long | long | long | float | double | def
+| float | float | float | float | float | float | float | double | def
+| double | double | double | double | double | double | double | double | def
+| def | def | def | def | def | def | def | def | def
+|====
+
+*Examples*
+
+* Addition operator with different numeric types.
++
+[source,Painless]
+----
+<1> int i = 29+4;
+<2> double d = i+7.0;
+----
++
+<1> declare `int i`;
+ add `int 29` and `int 4` -> `int 33`;
+ store `int 33` in `i`
+<2> declare `double d`;
+ load from `int i` -> `int 33`;
+ promote `int 33` and `double 7.0`: result `double`;
+ implicit cast `int 33` to `double 33.0` -> `double 33.0`;
+ add `double 33.0` and `double 7.0` -> `double 40.0`;
+ store `double 40.0` to `d`
++
+* Addition with the `def` type.
++
+[source,Painless]
+----
+<1> def x = 5+4;
+<2> def y = x+2;
+----
+<1> declare `def x`;
+ add `int 5` and `int 4` -> `int 9`;
+ implicit cast `int 9` to `def` -> `def`;
+ store `def` in `x`
+<2> declare `def y`;
+ load from `x` -> `def`;
+ implicit cast `def` to `int 9`;
+ add `int 9` and `int 2` -> `int 11`;
+ implicit cast `int 11` to `def` -> `def`;
+ store `def` to `y`
+
+[[subtraction-operator]]
+==== Subtraction
+
+Use the `subtraction operator '-'` to SUBTRACT a right-hand side numeric type
+value from a left-hand side numeric type value. Rules for resultant overflow
+and NaN values follow the JVM specification.
+
+*Errors*
+
+* If either of the values is a non-numeric type.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+subtraction: expression '-' expression;
+----
+
+*Promotion*
+
+[cols="<1,^1,^1,^1,^1,^1,^1,^1,^1"]
+|====
+| | byte | short | char | int | long | float | double | def
+| byte | int | int | int | int | long | float | double | def
+| short | int | int | int | int | long | float | double | def
+| char | int | int | int | int | long | float | double | def
+| int | int | int | int | int | long | float | double | def
+| long | long | long | long | long | long | float | double | def
+| float | float | float | float | float | float | float | double | def
+| double | double | double | double | double | double | double | double | def
+| def | def | def | def | def | def | def | def | def
+|====
+
+*Examples*
+
+* Subtraction with different numeric types.
++
+[source,Painless]
+----
+<1> int i = 29-4;
+<2> double d = i-7.5;
+----
++
+<1> declare `int i`;
+ subtract `int 4` from `int 29` -> `int 25`;
+ store `int 25` in `i`
+<2> declare `double d`
+ load from `int i` -> `int 25`;
+ promote `int 25` and `double 7.5`: result `double`;
+ implicit cast `int 25` to `double 25.0` -> `double 25.0`;
+ subtract `double 33.0` by `double 7.5` -> `double 25.5`;
+ store `double 25.5` to `d`
++
+* Subtraction with the `def` type.
++
+[source,Painless]
+----
+<1> def x = 5-4;
+<2> def y = x-2;
+----
+<1> declare `def x`;
+ subtract `int 4` and `int 5` -> `int 1`;
+ implicit cast `int 1` to `def` -> `def`;
+ store `def` in `x`
+<2> declare `def y`;
+ load from `x` -> `def`;
+ implicit cast `def` to `int 1`;
+ subtract `int 2` from `int 1` -> `int -1`;
+ implicit cast `int -1` to `def` -> `def`;
+ store `def` to `y`
+
+[[left-shift-operator]]
+==== Left Shift
+
+Use the `left shift operator '<<'` to SHIFT lower order bits to higher order
+bits in a left-hand side integer type value by the distance specified in a
+right-hand side integer type value.
+
+*Errors*
+
+* If either of the values is a non-integer type.
+* If the right-hand side value cannot be cast to an int type.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+left_shift: expression '<<' expression;
+----
+
+*Promotion*
+
+The left-hand side integer type value is promoted as specified in the table
+below. The right-hand side integer type value is always implicitly cast to an
+`int` type value and truncated to the number of bits of the promoted type value.
+
+[options="header",cols="<1,<1"]
+|====
+| original | promoted
+| byte | int
+| short | int
+| char | int
+| int | int
+| long | long
+| def | def
+|====
+
+*Examples*
+
+* Left shift with different integer types.
++
+[source,Painless]
+----
+<1> int i = 4 << 1;
+<2> long l = i << 2L;
+----
++
+<1> declare `int i`;
+ left shift `int 4` by `int 1` -> `int 8`;
+ store `int 8` in `i`
+<2> declare `long l`
+ load from `int i` -> `int 8`;
+ implicit cast `long 2` to `int 2` -> `int 2`;
+ left shift `int 8` by `int 2` -> `int 32`;
+ implicit cast `int 32` to `long 32` -> `long 32`;
+ store `long 32` to `l`
++
+* Left shift with the `def` type.
++
+[source,Painless]
+----
+<1> def x = 4 << 2;
+<2> def y = x << 1;
+----
+<1> declare `def x`;
+ left shift `int 4` by `int 2` -> `int 16`;
+ implicit cast `int 16` to `def` -> `def`;
+ store `def` in `x`
+<2> declare `def y`;
+ load from `x` -> `def`;
+ implicit cast `def` to `int 16`;
+ left shift `int 16` by `int 1` -> `int 32`;
+ implicit cast `int 32` to `def` -> `def`;
+ store `def` to `y`
+
+[[right-shift-operator]]
+==== Right Shift
+
+Use the `right shift operator '>>'` to SHIFT higher order bits to lower order
+bits in a left-hand side integer type value by the distance specified in a
+right-hand side integer type value. The highest order bit of the left-hand side
+integer type value is preserved.
+
+*Errors*
+
+* If either of the values is a non-integer type.
+* If the right-hand side value cannot be cast to an int type.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+right_shift: expression '>>' expression;
+----
+
+*Promotion*
+
+The left-hand side integer type value is promoted as specified in the table
+below. The right-hand side integer type value is always implicitly cast to an
+`int` type value and truncated to the number of bits of the promoted type value.
+
+[options="header",cols="<1,<1"]
+|====
+| original | promoted
+| byte | int
+| short | int
+| char | int
+| int | int
+| long | long
+| def | def
+|====
+
+*Examples*
+
+* Right shift with different integer types.
++
+[source,Painless]
+----
+<1> int i = 32 >> 1;
+<2> long l = i >> 2L;
+----
++
+<1> declare `int i`;
+ right shift `int 32` by `int 1` -> `int 16`;
+ store `int 16` in `i`
+<2> declare `long l`
+ load from `int i` -> `int 16`;
+ implicit cast `long 2` to `int 2` -> `int 2`;
+ right shift `int 16` by `int 2` -> `int 4`;
+ implicit cast `int 4` to `long 4` -> `long 4`;
+ store `long 4` to `l`
++
+* Right shift with the `def` type.
++
+[source,Painless]
+----
+<1> def x = 16 >> 2;
+<2> def y = x >> 1;
+----
+<1> declare `def x`;
+ right shift `int 16` by `int 2` -> `int 4`;
+ implicit cast `int 4` to `def` -> `def`;
+ store `def` in `x`
+<2> declare `def y`;
+ load from `x` -> `def`;
+ implicit cast `def` to `int 4`;
+ right shift `int 4` by `int 1` -> `int 2`;
+ implicit cast `int 2` to `def` -> `def`;
+ store `def` to `y`
+
+[[unsigned-right-shift-operator]]
+==== Unsigned Right Shift
+
+Use the `unsigned right shift operator '>>>'` to SHIFT higher order bits to
+lower order bits in a left-hand side integer type value by the distance
+specified in a right-hand side type integer value. The highest order bit of the
+left-hand side integer type value is *not* preserved.
+
+*Errors*
+
+* If either of the values is a non-integer type.
+* If the right-hand side value cannot be cast to an int type.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+unsigned_right_shift: expression '>>>' expression;
+----
+
+*Promotion*
+
+The left-hand side integer type value is promoted as specified in the table
+below. The right-hand side integer type value is always implicitly cast to an
+`int` type value and truncated to the number of bits of the promoted type value.
+
+[options="header",cols="<1,<1"]
+|====
+| original | promoted
+| byte | int
+| short | int
+| char | int
+| int | int
+| long | long
+| def | def
+|====
+
+*Examples*
+
+* Unsigned right shift with different integer types.
++
+[source,Painless]
+----
+<1> int i = -1 >>> 29;
+<2> long l = i >>> 2L;
+----
++
+<1> declare `int i`;
+ unsigned right shift `int -1` by `int 29` -> `int 7`;
+ store `int 7` in `i`
+<2> declare `long l`
+ load from `int i` -> `int 7`;
+ implicit cast `long 2` to `int 2` -> `int 2`;
+ unsigned right shift `int 7` by `int 2` -> `int 3`;
+ implicit cast `int 3` to `long 3` -> `long 3`;
+ store `long 3` to `l`
++
+* Unsigned right shift with the `def` type.
++
+[source,Painless]
+----
+<1> def x = 16 >>> 2;
+<2> def y = x >>> 1;
+----
+<1> declare `def x`;
+ unsigned right shift `int 16` by `int 2` -> `int 4`;
+ implicit cast `int 4` to `def` -> `def`;
+ store `def` in `x`
+<2> declare `def y`;
+ load from `x` -> `def`;
+ implicit cast `def` to `int 4`;
+ unsigned right shift `int 4` by `int 1` -> `int 2`;
+ implicit cast `int 2` to `def` -> `def`;
+ store `def` to `y`
+
+[[bitwise-and-operator]]
+==== Bitwise And
+
+Use the `bitwise and operator '&'` to AND together each bit within two
+integer type values where if both bits at the same index are `1` the resultant
+bit is `1` and `0` otherwise.
+
+*Errors*
+
+* If either of the values is a non-integer type.
+
+*Bits*
+
+[cols="^1,^1,^1"]
+|====
+| | 1 | 0
+| 1 | 1 | 0
+| 0 | 0 | 0
+|====
+
+*Grammar*
+
+[source,ANTLR4]
+----
+bitwise_and: expression '&' expression;
+----
+
+*Promotion*
+
+[cols="<1,^1,^1,^1,^1,^1,^1"]
+|====
+| | byte | short | char | int | long | def
+| byte | int | int | int | int | long | def
+| short | int | int | int | int | long | def
+| char | int | int | int | int | long | def
+| int | int | int | int | int | long | def
+| long | long | long | long | long | long | def
+| def | def | def | def | def | def | def
+|====
+
+*Examples*
+
+* Bitwise and with different integer types.
++
+[source,Painless]
+----
+<1> int i = 5 & 6;
+<2> long l = i & 5L;
+----
++
+<1> declare `int i`;
+ bitwise and `int 5` and `int 6` -> `int 4`;
+ store `int 4` in `i`
+<2> declare `long l`
+ load from `int i` -> `int 4`;
+ promote `int 4` and `long 5`: result `long`;
+ implicit cast `int 4` to `long 4` -> `long 4`;
+ bitwise and `long 4` and `long 5` -> `long 4`;
+ store `long 4` to `l`
++
+* Bitwise and with the `def` type.
++
+[source,Painless]
+----
+<1> def x = 15 & 6;
+<2> def y = x & 5;
+----
+<1> declare `def x`;
+ bitwise and `int 15` and `int 6` -> `int 6`;
+ implicit cast `int 6` to `def` -> `def`;
+ store `def` in `x`
+<2> declare `def y`;
+ load from `x` -> `def`;
+ implicit cast `def` to `int 6`;
+ bitwise and `int 6` and `int 5` -> `int 4`;
+ implicit cast `int 4` to `def` -> `def`;
+ store `def` to `y`
+
+[[bitwise-xor-operator]]
+==== Bitwise Xor
+
+Use the `bitwise xor operator '^'` to XOR together each bit within two integer
+type values where if one bit is a `1` and the other bit is a `0` at the same
+index the resultant bit is `1` otherwise the resultant bit is `0`.
+
+*Errors*
+
+* If either of the values is a non-integer type.
+
+*Bits*
+
+The following table illustrates the resultant bit from the xoring of two bits.
+
+[cols="^1,^1,^1"]
+|====
+| | 1 | 0
+| 1 | 0 | 1
+| 0 | 1 | 0
+|====
+
+*Grammar*
+
+[source,ANTLR4]
+----
+bitwise_and: expression '^' expression;
+----
+
+*Promotion*
+
+[cols="<1,^1,^1,^1,^1,^1,^1"]
+|====
+| | byte | short | char | int | long | def
+| byte | int | int | int | int | long | def
+| short | int | int | int | int | long | def
+| char | int | int | int | int | long | def
+| int | int | int | int | int | long | def
+| long | long | long | long | long | long | def
+| def | def | def | def | def | def | def
+|====
+
+*Examples*
+
+* Bitwise xor with different integer types.
++
+[source,Painless]
+----
+<1> int i = 5 ^ 6;
+<2> long l = i ^ 5L;
+----
++
+<1> declare `int i`;
+ bitwise xor `int 5` and `int 6` -> `int 3`;
+ store `int 3` in `i`
+<2> declare `long l`
+ load from `int i` -> `int 4`;
+ promote `int 3` and `long 5`: result `long`;
+ implicit cast `int 3` to `long 3` -> `long 3`;
+ bitwise xor `long 3` and `long 5` -> `long 6`;
+ store `long 6` to `l`
++
+* Bitwise xor with the `def` type.
++
+[source,Painless]
+----
+<1> def x = 15 ^ 6;
+<2> def y = x ^ 5;
+----
+<1> declare `def x`;
+ bitwise xor `int 15` and `int 6` -> `int 9`;
+ implicit cast `int 9` to `def` -> `def`;
+ store `def` in `x`
+<2> declare `def y`;
+ load from `x` -> `def`;
+ implicit cast `def` to `int 9`;
+ bitwise xor `int 9` and `int 5` -> `int 12`;
+ implicit cast `int 12` to `def` -> `def`;
+ store `def` to `y`
+
+[[bitwise-or-operator]]
+==== Bitwise Or
+
+Use the `bitwise or operator '|'` to OR together each bit within two integer
+type values where if at least one bit is a `1` at the same index the resultant
+bit is `1` otherwise the resultant bit is `0`.
+
+*Errors*
+
+* If either of the values is a non-integer type.
+
+*Bits*
+
+The following table illustrates the resultant bit from the oring of two bits.
+
+[cols="^1,^1,^1"]
+|====
+| | 1 | 0
+| 1 | 1 | 1
+| 0 | 1 | 0
+|====
+
+*Grammar*
+
+[source,ANTLR4]
+----
+bitwise_and: expression '|' expression;
+----
+
+*Promotion*
+
+[cols="<1,^1,^1,^1,^1,^1,^1"]
+|====
+| | byte | short | char | int | long | def
+| byte | int | int | int | int | long | def
+| short | int | int | int | int | long | def
+| char | int | int | int | int | long | def
+| int | int | int | int | int | long | def
+| long | long | long | long | long | long | def
+| def | def | def | def | def | def | def
+|====
+
+*Examples*
+
+* Bitwise or with different integer types.
++
+[source,Painless]
+----
+<1> int i = 5 | 6;
+<2> long l = i | 8L;
+----
++
+<1> declare `int i`;
+ bitwise or `int 5` and `int 6` -> `int 7`;
+ store `int 7` in `i`
+<2> declare `long l`
+ load from `int i` -> `int 7`;
+ promote `int 7` and `long 8`: result `long`;
+ implicit cast `int 7` to `long 7` -> `long 7`;
+ bitwise or `long 7` and `long 8` -> `long 15`;
+ store `long 15` to `l`
++
+* Bitwise or with the `def` type.
++
+[source,Painless]
+----
+<1> def x = 5 ^ 6;
+<2> def y = x ^ 8;
+----
+<1> declare `def x`;
+ bitwise or `int 5` and `int 6` -> `int 7`;
+ implicit cast `int 7` to `def` -> `def`;
+ store `def` in `x`
+<2> declare `def y`;
+ load from `x` -> `def`;
+ implicit cast `def` to `int 7`;
+ bitwise or `int 7` and `int 8` -> `int 15`;
+ implicit cast `int 15` to `def` -> `def`;
+ store `def` to `y`
\ No newline at end of file
diff --git a/docs/painless/painless-operators-reference.asciidoc b/docs/painless/painless-operators-reference.asciidoc
new file mode 100644
index 00000000000..487fcce15f3
--- /dev/null
+++ b/docs/painless/painless-operators-reference.asciidoc
@@ -0,0 +1,774 @@
+[[painless-operators-reference]]
+=== Operators: Reference
+
+[[method-call-operator]]
+==== Method Call
+
+Use the `method call operator '()'` to call a member method on a
+<> value. Implicit
+<> is evaluated as necessary per argument
+during the method call. When a method call is made on a target `def` type value,
+the parameters and return type value are considered to also be of the `def` type
+and are evaluated at run-time.
+
+An overloaded method is one that shares the same name with two or more methods.
+A method is overloaded based on arity where the same name is re-used for
+multiple methods as long as the number of parameters differs.
+
+*Errors*
+
+* If the reference type value is `null`.
+* If the member method name doesn't exist for a given reference type value.
+* If the number of arguments passed in is different from the number of specified
+ parameters.
+* If the arguments cannot be implicitly cast or implicitly boxed/unboxed to the
+ correct type values for the parameters.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+method_call: '.' ID arguments;
+arguments: '(' (expression (',' expression)*)? ')';
+----
+
+*Examples*
+
+* Method calls on different reference types.
++
+[source,Painless]
+----
+<1> Map m = new HashMap();
+<2> m.put(1, 2);
+<3> int z = m.get(1);
+<4> def d = new ArrayList();
+<5> d.add(1);
+<6> int i = Integer.parseInt(d.get(0).toString());
+----
++
+<1> declare `Map m`;
+ allocate `HashMap` instance -> `HashMap reference`;
+ store `HashMap reference` to `m`
+<2> load from `m` -> `Map reference`;
+ implicit cast `int 1` to `def` -> `def`;
+ implicit cast `int 2` to `def` -> `def`;
+ call `put` on `Map reference` with arguments (`int 1`, `int 2`)
+<3> declare `int z`;
+ load from `m` -> `Map reference`;
+ call `get` on `Map reference` with arguments (`int 1`) -> `def`;
+ implicit cast `def` to `int 2` -> `int 2`;
+ store `int 2` to `z`
+<4> declare `def d`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList` to `def` -> `def`;
+ store `def` to `d`
+<5> load from `d` -> `def`;
+ implicit cast `def` to `ArrayList reference` -> `ArrayList reference`
+ call `add` on `ArrayList reference` with arguments (`int 1`);
+<6> declare `int i`;
+ load from `d` -> `def`;
+ implicit cast `def` to `ArrayList reference` -> `ArrayList reference`
+ call `get` on `ArrayList reference` with arguments (`int 1`) -> `def`;
+ implicit cast `def` to `Integer 1 reference` -> `Integer 1 reference`;
+ call `toString` on `Integer 1 reference` -> `String '1'`;
+ call `parseInt` on `Integer` with arguments (`String '1'`) -> `int 1`;
+ store `int 1` in `i`;
+
+[[field-access-operator]]
+==== Field Access
+
+Use the `field access operator '.'` to store a value to or load a value from a
+<> member field.
+
+*Errors*
+
+* If the reference type value is `null`.
+* If the member field name doesn't exist for a given reference type value.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+field_access: '.' ID;
+----
+
+*Examples*
+
+The examples use the following reference type definition:
+
+[source,Painless]
+----
+name:
+ Example
+
+non-static member fields:
+ * int x
+ * def y
+ * List z
+----
+
+* Field access with the `Example` type.
++
+[source,Painless]
+----
+<1> Example example = new Example();
+<2> example.x = 1;
+<3> example.y = example.x;
+<4> example.z = new ArrayList();
+<5> example.z.add(1);
+<6> example.x = example.z.get(0);
+----
++
+<1> declare `Example example`;
+ allocate `Example` instance -> `Example reference`;
+ store `Example reference` to `example`
+<2> load from `example` -> `Example reference`;
+ store `int 1` to `x` of `Example reference`
+<3> load from `example` -> `Example reference @0`;
+ load from `example` -> `Example reference @1`;
+ load from `x` of `Example reference @1` -> `int 1`;
+ implicit cast `int 1` to `def` -> `def`;
+ store `def` to `y` of `Example reference @0`;
+ (note `Example reference @0` and `Example reference @1` are the same)
+<4> load from `example` -> `Example reference`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `List reference` -> `List reference`;
+ store `List reference` to `z` of `Example reference`
+<5> load from `example` -> `Example reference`;
+ load from `z` of `Example reference` -> `List reference`;
+ call `add` on `List reference` with arguments (`int 1`)
+<6> load from `example` -> `Example reference @0`;
+ load from `example` -> `Example reference @1`;
+ load from `z` of `Example reference @1` -> `List reference`;
+ call `get` on `List reference` with arguments (`int 0`) -> `int 1`;
+ store `int 1` in `x` of `List reference @0`;
+ (note `Example reference @0` and `Example reference @1` are the same)
+
+[[null-safe-operator]]
+==== Null Safe
+
+Use the `null safe operator '?.'` instead of the method call operator or field
+access operator to ensure a reference type value is `non-null` before
+a method call or field access. A `null` value will be returned if the reference
+type value is `null`, otherwise the method call or field access is evaluated.
+
+*Errors*
+
+* If the method call return type value or the field access type value is not
+ a reference type value and is not implicitly castable to a reference type
+ value.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+null_safe: null_safe_method_call
+ | null_safe_field_access
+ ;
+
+null_safe_method_call: '?.' ID arguments;
+arguments: '(' (expression (',' expression)*)? ')';
+
+null_safe_field_access: '?.' ID;
+----
+
+*Examples*
+
+The examples use the following reference type definition:
+
+[source,Painless]
+----
+name:
+ Example
+
+non-static member methods:
+ * List factory()
+
+non-static member fields:
+ * List x
+----
+
+* Null safe without a `null` value.
++
+[source,Painless]
+----
+<1> Example example = new Example();
+<2> List x = example?.factory();
+----
++
+<1> declare `Example example`;
+ allocate `Example` instance -> `Example reference`;
+ store `Example reference` to `example`
+<2> declare `List x`;
+ load from `example` -> `Example reference`;
+ null safe call `factory` on `Example reference` -> `List reference`;
+ store `List reference` to `x`;
++
+* Null safe with a `null` value;
++
+[source,Painless]
+----
+<1> Example example = null;
+<2> List x = example?.x;
+----
+<1> declare `Example example`;
+ store `null` to `example`
+<2> declare `List x`;
+ load from `example` -> `Example reference`;
+ null safe access `x` on `Example reference` -> `null`;
+ store `null` to `x`;
+ (note the *null safe operator* returned `null` because `example` is `null`)
+
+[[list-initialization-operator]]
+==== List Initialization
+
+Use the `list initialization operator '[]'` to allocate an `List` type instance
+to the heap with a set of pre-defined values. Each value used to initialize the
+`List` type instance is cast to a `def` type value upon insertion into the
+`List` type instance using the `add` method. The order of the specified values
+is maintained.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+list_initialization: '[' expression (',' expression)* ']'
+ | '[' ']';
+----
+
+*Examples*
+
+* List initialization of an empty `List` type value.
++
+[source,Painless]
+----
+<1> List empty = [];
+----
++
+<1> declare `List empty`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `List reference` -> `List reference`;
+ store `List reference` to `empty`
++
+* List initialization with static values.
++
+[source,Painless]
+----
+<1> List list = [1, 2, 3];
+----
++
+<1> declare `List list`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ call `add` on `ArrayList reference` with arguments(`int 1`);
+ call `add` on `ArrayList reference` with arguments(`int 2`);
+ call `add` on `ArrayList reference` with arguments(`int 3`);
+ implicit cast `ArrayList reference` to `List reference` -> `List reference`;
+ store `List reference` to `list`
++
+* List initialization with non-static values.
++
+[source,Painless]
+----
+<1> int i = 1;
+<2> long l = 2L;
+<3> float f = 3.0F;
+<4> double d = 4.0;
+<5> String s = "5";
+<6> List list = [i, l, f*d, s];
+----
++
+<1> declare `int i`;
+ store `int 1` to `i`
+<2> declare `long l`;
+ store `long 2` to `l`
+<3> declare `float f`;
+ store `float 3.0` to `f`
+<4> declare `double d`;
+ store `double 4.0` to `d`
+<5> declare `String s`;
+ store `String "5"` to `s`
+<6> declare `List list`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ load from `i` -> `int 1`;
+ call `add` on `ArrayList reference` with arguments(`int 1`);
+ load from `l` -> `long 2`;
+ call `add` on `ArrayList reference` with arguments(`long 2`);
+ load from `f` -> `float 3.0`;
+ load from `d` -> `double 4.0`;
+ promote `float 3.0` and `double 4.0`: result `double`;
+ implicit cast `float 3.0` to `double 3.0` -> `double 3.0`;
+ multiply `double 3.0` and `double 4.0` -> `double 12.0`;
+ call `add` on `ArrayList reference` with arguments(`double 12.0`);
+ load from `s` -> `String "5"`;
+ call `add` on `ArrayList reference` with arguments(`String "5"`);
+ implicit cast `ArrayList reference` to `List reference` -> `List reference`;
+ store `List reference` to `list`
+
+[[list-access-operator]]
+==== List Access
+
+Use the `list access operator '[]'` as a shortcut for a `set` method call or
+`get` method call made on a `List` type value.
+
+*Errors*
+
+* If a value other than a `List` type value is accessed.
+* If a non-integer type value is used as an index for a `set` method call or
+ `get` method call.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+list_access: '[' expression ']'
+----
+
+*Examples*
+
+* List access with the `List` type.
++
+[source,Painless]
+----
+<1> List list = new ArrayList();
+<2> list.add(1);
+<3> list.add(2);
+<4> list.add(3);
+<5> list[0] = 2;
+<6> list[1] = 5;
+<7> int x = list[0] + list[1];
+<8> int y = 1;
+<9> int z = list[y];
+----
++
+<1> declare `List list`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `List reference` -> `List reference`;
+ store `List reference` to `list`
+<2> load from `list` -> `List reference`;
+ call `add` on `List reference` with arguments(`int 1`)
+<3> load from `list` -> `List reference`;
+ call `add` on `List reference` with arguments(`int 2`)
+<4> load from `list` -> `List reference`;
+ call `add` on `List reference` with arguments(`int 3`)
+<5> load from `list` -> `List reference`;
+ call `set` on `List reference` with arguments(`int 0`, `int 2`)
+<6> load from `list` -> `List reference`;
+ call `set` on `List reference` with arguments(`int 1`, `int 5`)
+<7> declare `int x`;
+ load from `list` -> `List reference`;
+ call `get` on `List reference` with arguments(`int 0`) -> `def`;
+ implicit cast `def` to `int 2` -> `int 2`;
+ load from `list` -> `List reference`;
+ call `get` on `List reference` with arguments(`int 1`) -> `def`;
+ implicit cast `def` to `int 5` -> `int 5`;
+ add `int 2` and `int 5` -> `int 7`;
+ store `int 7` to `x`
+<8> declare `int y`;
+ store `int 1` int `y`
+<9> declare `int z`;
+ load from `list` -> `List reference`;
+ load from `y` -> `int 1`;
+ call `get` on `List reference` with arguments(`int 1`) -> `def`;
+ implicit cast `def` to `int 5` -> `int 5`;
+ store `int 5` to `z`
++
+* List access with the `def` type.
++
+[source,Painless]
+----
+<1> def d = new ArrayList();
+<2> d.add(1);
+<3> d.add(2);
+<4> d.add(3);
+<5> d[0] = 2;
+<6> d[1] = 5;
+<7> def x = d[0] + d[1];
+<8> def y = 1;
+<9> def z = d[y];
+----
++
+<1> declare `List d`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `def` -> `def`;
+ store `def` to `d`
+<2> load from `d` -> `def`;
+ implicit cast `def` to `ArrayList reference` -> `ArrayList reference`;
+ call `add` on `ArrayList reference` with arguments(`int 1`)
+<3> load from `d` -> `def`;
+ implicit cast `def` to `ArrayList reference` -> `ArrayList reference`;
+ call `add` on `ArrayList reference` with arguments(`int 2`)
+<4> load from `d` -> `def`;
+ implicit cast `def` to `ArrayList reference` -> `ArrayList reference`;
+ call `add` on `ArrayList reference` with arguments(`int 3`)
+<5> load from `d` -> `def`;
+ implicit cast `def` to `ArrayList reference` -> `ArrayList reference`;
+ call `set` on `ArrayList reference` with arguments(`int 0`, `int 2`)
+<6> load from `d` -> `def`;
+ implicit cast `def` to `ArrayList reference` -> `ArrayList reference`;
+ call `set` on `ArrayList reference` with arguments(`int 1`, `int 5`)
+<7> declare `def x`;
+ load from `d` -> `def`;
+ implicit cast `def` to `ArrayList reference` -> `ArrayList reference`;
+ call `get` on `ArrayList reference` with arguments(`int 0`) -> `def`;
+ implicit cast `def` to `int 2` -> `int 2`;
+ load from `d` -> `def`;
+ implicit cast `def` to `ArrayList reference` -> `ArrayList reference`;
+ call `get` on `ArrayList reference` with arguments(`int 1`) -> `def`;
+ implicit cast `def` to `int 2` -> `int 2`;
+ add `int 2` and `int 5` -> `int 7`;
+ store `int 7` to `x`
+<8> declare `int y`;
+ store `int 1` int `y`
+<9> declare `int z`;
+ load from `d` -> `ArrayList reference`;
+ load from `y` -> `def`;
+ implicit cast `def` to `int 1` -> `int 1`;
+ call `get` on `ArrayList reference` with arguments(`int 1`) -> `def`;
+ store `def` to `z`
+
+[[map-initialization-operator]]
+==== Map Initialization
+
+Use the `map initialization operator '[:]'` to allocate a `Map` type instance to
+the heap with a set of pre-defined values. Each pair of values used to
+initialize the `Map` type instance are cast to `def` type values upon insertion
+into the `Map` type instance using the `put` method.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+map_initialization: '[' key_pair (',' key_pair)* ']'
+ | '[' ':' ']';
+key_pair: expression ':' expression
+----
+
+*Examples*
+
+* Map initialization of an empty `Map` type value.
++
+[source,Painless]
+----
+<1> Map empty = [:];
+----
++
+<1> declare `Map empty`;
+ allocate `HashMap` instance -> `HashMap reference`;
+ implicit cast `HashMap reference` to `Map reference` -> `Map reference`;
+ store `Map reference` to `empty`
++
+* Map initialization with static values.
++
+[source,Painless]
+----
+<1> Map map = [1:2, 3:4, 5:6];
+----
++
+<1> declare `Map map`;
+ allocate `HashMap` instance -> `HashMap reference`;
+ call `put` on `HashMap reference` with arguments(`int 1`, `int 2`);
+ call `put` on `HashMap reference` with arguments(`int 3`, `int 4`);
+ call `put` on `HashMap reference` with arguments(`int 5`, `int 6`);
+ implicit cast `HashMap reference` to `Map reference` -> `Map reference`;
+ store `Map reference` to `map`
++
+* Map initialization with non-static values.
++
+[source,Painless]
+----
+<1> byte b = 0;
+<2> int i = 1;
+<3> long l = 2L;
+<4> float f = 3.0F;
+<5> double d = 4.0;
+<6> String s = "5";
+<7> Map map = [b:i, l:f*d, d:s];
+----
++
+<1> declare `byte b`;
+ store `byte 0` to `b`
+<2> declare `int i`;
+ store `int 1` to `i`
+<3> declare `long l`;
+ store `long 2` to `l`
+<4> declare `float f`;
+ store `float 3.0` to `f`
+<5> declare `double d`;
+ store `double 4.0` to `d`
+<6> declare `String s`;
+ store `String "5"` to `s`
+<7> declare `Map map`;
+ allocate `HashMap` instance -> `HashMap reference`;
+ load from `b` -> `byte 0`;
+ load from `i` -> `int 1`;
+ call `put` on `HashMap reference` with arguments(`byte 0`, `int 1`);
+ load from `l` -> `long 2`;
+ load from `f` -> `float 3.0`;
+ load from `d` -> `double 4.0`;
+ promote `float 3.0` and `double 4.0`: result `double`;
+ implicit cast `float 3.0` to `double 3.0` -> `double 3.0`;
+ multiply `double 3.0` and `double 4.0` -> `double 12.0`;
+ call `put` on `HashMap reference` with arguments(`long 2`, `double 12.0`);
+ load from `d` -> `double 4.0`;
+ load from `s` -> `String "5"`;
+ call `put` on `HashMap reference` with
+ arguments(`double 4.0`, `String "5"`);
+ implicit cast `HashMap reference` to `Map reference` -> `Map reference`;
+ store `Map reference` to `map`
+
+[[map-access-operator]]
+==== Map Access
+
+Use the `map access operator '[]'` as a shortcut for a `put` method call or
+`get` method call made on a `Map` type value.
+
+*Errors*
+
+* If a value other than a `Map` type value is accessed.
+
+*Grammar*
+[source,ANTLR4]
+----
+map_access: '[' expression ']'
+----
+
+*Examples*
+
+* Map access with the `Map` type.
++
+[source,Painless]
+----
+<1> Map map = new HashMap();
+<2> map['value2'] = 2;
+<3> map['value5'] = 5;
+<4> int x = map['value2'] + map['value5'];
+<5> String y = 'value5';
+<6> int z = x[z];
+----
++
+<1> declare `Map map`;
+ allocate `HashMap` instance -> `HashMap reference`;
+ implicit cast `HashMap reference` to `Map reference` -> `Map reference`;
+ store `Map reference` to `map`
+<2> load from `map` -> `Map reference`;
+ call `put` on `Map reference` with arguments(`String 'value2'`, `int 2`)
+<3> load from `map` -> `Map reference`;
+ call `put` on `Map reference` with arguments(`String 'value5'`, `int 5`)
+<4> declare `int x`;
+ load from `map` -> `Map reference`;
+ call `get` on `Map reference` with arguments(`String 'value2'`) -> `def`;
+ implicit cast `def` to `int 2` -> `int 2`;
+ load from `map` -> `Map reference`;
+ call `get` on `Map reference` with arguments(`String 'value5'`) -> `def`;
+ implicit cast `def` to `int 5` -> `int 5`;
+ add `int 2` and `int 5` -> `int 7`;
+ store `int 7` to `x`
+<5> declare `String y`;
+ store `String 'value5'` to `y`
+<6> declare `int z`;
+ load from `map` -> `Map reference`;
+ load from `y` -> `String 'value5'`;
+ call `get` on `Map reference` with arguments(`String 'value5'`) -> `def`;
+ implicit cast `def` to `int 5` -> `int 5`;
+ store `int 5` to `z`
++
+* Map access with the `def` type.
++
+[source,Painless]
+----
+<1> def d = new HashMap();
+<2> d['value2'] = 2;
+<3> d['value5'] = 5;
+<4> int x = d['value2'] + d['value5'];
+<5> String y = 'value5';
+<6> def z = d[y];
+----
++
+<1> declare `def d`;
+ allocate `HashMap` instance -> `HashMap reference`;
+ implicit cast `HashMap reference` to `def` -> `def`;
+ store `def` to `d`
+<2> load from `d` -> `def`;
+ implicit cast `def` to `HashMap reference` -> `HashMap reference`;
+ call `put` on `HashMap reference` with arguments(`String 'value2'`, `int 2`)
+<3> load from `d` -> `def`;
+ implicit cast `def` to `HashMap reference` -> `HashMap reference`;
+ call `put` on `HashMap reference` with arguments(`String 'value5'`, `int 5`)
+<4> declare `int x`;
+ load from `d` -> `def`;
+ implicit cast `def` to `HashMap reference` -> `HashMap reference`;
+ call `get` on `HashMap reference` with arguments(`String 'value2'`)
+ -> `def`;
+ implicit cast `def` to `int 2` -> `int 2`;
+ load from `d` -> `def`;
+ call `get` on `HashMap reference` with arguments(`String 'value5'`)
+ -> `def`;
+ implicit cast `def` to `int 5` -> `int 5`;
+ add `int 2` and `int 5` -> `int 7`;
+ store `int 7` to `x`
+<5> declare `String y`;
+ store `String 'value5'` to `y`
+<6> declare `def z`;
+ load from `d` -> `def`;
+ load from `y` -> `String 'value5'`;
+ call `get` on `HashMap reference` with arguments(`String 'value5'`)
+ -> `def`;
+ store `def` to `z`
+
+[[new-instance-operator]]
+==== New Instance
+
+Use the `new instance operator 'new ()'` to allocate a
+<> instance to the heap and call a specified
+constructor. Implicit <> is evaluated as
+necessary per argument during the constructor call.
+
+An overloaded constructor is one that shares the same name with two or more
+constructors. A constructor is overloaded based on arity where the same
+reference type name is re-used for multiple constructors as long as the number
+of parameters differs.
+
+*Errors*
+
+* If the reference type name doesn't exist for instance allocation.
+* If the number of arguments passed in is different from the number of specified
+ parameters.
+* If the arguments cannot be implicitly cast or implicitly boxed/unboxed to the
+ correct type values for the parameters.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+new_instance: 'new' TYPE '(' (expression (',' expression)*)? ')';
+----
+
+*Examples*
+
+* Allocation of new instances with different types.
+
+[source,Painless]
+----
+<1> Map m = new HashMap();
+<2> def d = new ArrayList();
+<3> def e = new HashMap(m);
+----
+<1> declare `Map m`;
+ allocate `HashMap` instance -> `HashMap reference`;
+ implicit cast `HashMap reference` to `Map reference` -> `Map reference`;
+ store `Map reference` to `m`;
+<2> declare `def d`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `def` -> `def`;
+ store `def` to `d`;
+<3> declare `def e`;
+ load from `m` -> `Map reference`;
+ allocate `HashMap` instance with arguments (`Map reference`)
+ -> `HashMap reference`;
+ implicit cast `HashMap reference` to `def` -> `def`;
+ store `def` to `e`;
+
+[[string-concatenation-operator]]
+==== String Concatenation
+
+Use the `string concatenation operator '+'` to concatenate two values together
+where at least one of the values is a <>.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+concatenate: expression '+' expression;
+----
+
+*Examples*
+
+* String concatenation with different primitive types.
++
+[source,Painless]
+----
+<1> String x = "con";
+<2> String y = x + "cat";
+<3> String z = 4 + 5 + x;
+----
++
+<1> declare `String x`;
+ store `String "con"` to `x`;
+<2> declare `String y`;
+ load from `x` -> `String "con"`;
+ concat `String "con"` and `String "cat"` -> `String "concat"`;
+ store `String "concat"` to `y`
+<3> declare `String z`;
+ add `int 4` and `int 5` -> `int 9`;
+ concat `int 9` and `String "9concat"`;
+ store `String "9concat"` to `z`;
+ (note the addition is done prior to the concatenation due to precedence and
+ associativity of the specific operations)
++
+* String concatenation with the `def` type.
++
+[source,Painless]
+----
+<1> def d = 2;
+<2> d = "con" + d + "cat";
+----
++
+<1> declare `def`;
+ implicit cast `int 2` to `def` -> `def`;
+ store `def` in `d`;
+<2> concat `String "con"` and `int 9` -> `String "con9"`;
+ concat `String "con9"` and `String "con"` -> `String "con9cat"`
+ implicit cast `String "con9cat"` to `def` -> `def`;
+ store `def` to `d`;
+ (note the switch in type of `d` from `int` to `String`)
+
+[[elvis-operator]]
+==== Elvis
+
+An elvis consists of two expressions. The first expression is evaluated
+with to check for a `null` value. If the first expression evaluates to
+`null` then the second expression is evaluated and its value used. If the first
+expression evaluates to `non-null` then the resultant value of the first
+expression is used. Use the `elvis operator '?:'` as a shortcut for the
+conditional operator.
+
+*Errors*
+
+* If the first expression or second expression cannot produce a `null` value.
+
+*Grammar*
+
+[source,ANTLR4]
+----
+elvis: expression '?:' expression;
+----
+
+*Examples*
+
+* Elvis with different reference types.
++
+[source,Painless]
+----
+<1> List x = new ArrayList();
+<2> List y = x ?: new ArrayList();
+<3> y = null;
+<4> List z = y ?: new ArrayList();
+----
++
+<1> declare `List x`;
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `List reference` -> `List reference`;
+ store `List reference` to `x`;
+<2> declare `List y`;
+ load `x` -> `List reference`;
+ `List reference` equals `null` -> `false`;
+ evaluate 1st expression: `List reference` -> `List reference`;
+ store `List reference` to `y`
+<3> store `null` to `y`;
+<4> declare `List z`;
+ load `y` -> `List reference`;
+ `List reference` equals `null` -> `true`;
+ evaluate 2nd expression:
+ allocate `ArrayList` instance -> `ArrayList reference`;
+ implicit cast `ArrayList reference` to `List reference` -> `List reference`;
+ store `List reference` to `z`;
diff --git a/docs/painless/painless-operators.asciidoc b/docs/painless/painless-operators.asciidoc
index 8329686f663..b51e94088a6 100644
--- a/docs/painless/painless-operators.asciidoc
+++ b/docs/painless/painless-operators.asciidoc
@@ -1,1819 +1,64 @@
[[painless-operators]]
=== Operators
-The following is a table of the available operators in Painless. Each operator will have further information and examples outside of the table. Many operators will have a promotion table as described by the documentation on promotion [MARK].
-
-[options="header",cols="6,3,2,4"]
-|====
-|Operator|Symbol(s)|Precedence|Associativity
-|Precedence|()|0|left-to-right
-|Field Access|.|1|left-to-right
-|Method Call|. ()|1|left-to-right
-|Null Safe|?.|1|left-to-right
-|Function Call|()|1|left-to-right
-|Array Initialization|[] {}|1|left-to-right
-|Array Access|[]|1|left-to-right
-|Array Length|.|1|left-to-right
-|List Initialization|[]|1|left-to-right
-|List Access|[]|1|left-to-right
-|Map Initialization|[:]|1|left-to-right
-|Map Access|[]|1|left-to-right
-|Post Increment|++|1|left-to-right
-|Post Decrement|--|1|left-to-right
-|Pre Increment|++|2|right-to-left
-|Pre Decrement|--|2|right-to-left
-|Unary Positive|+|2|right-to-left
-|Unary Negative|-|2|right-to-left
-|Boolean Not|!|2|right-to-left
-|Bitwise Not|~|2|right-to-left
-|Cast|()|3|right-to-left
-|Constructor Call|new ()|3|right-to-left
-|New Array|new|3|right-to-left
-|Multiplication|*|4|left-to-right
-|Division|/|4|left-to-right
-|Remainder|%|4|left-to-right
-|String Concatenation|+|5|left-to-right
-|Addition|+|5|left-to-right
-|Subtraction|-|5|left-to-right
-|Left Shift|<<|6|left-to-right
-|Right Shift|>>|6|left-to-right
-|Unsigned Right Shift|>>>|6|left-to-right
-|Greater Than|>|7|left-to-right
-|Greater Than Or Equal|>=|7|left-to-right
-|Less Than|<|7|left-to-right
-|Less Than Or Equal|<=|7|left-to-right
-|Instance Of|instanceof|8|left-to-right
-|Equality Equals|==|9|left-to-right
-|Equality Not Equals|!=|9|left-to-right
-|Identity Equals|===|9|left-to-right
-|Identity Not Equals|!==|9|left-to-right
-|Bitwise And|&|10|left-to-right
-|Boolean Xor|^|11|left-to-right
-|Bitwise Xor|^|11|left-to-right
-|Bitwise Or|\||12|left-to-right
-|Boolean And|&&|13|left-to-right
-|Boolean Or|\|\||14|left-to-right
-|Conditional|? :|15|right-to-left
-|Elvis|?:|16|right-to-left
-|Assignment|=|17|right-to-left
-|Compound Assignment|$=|17|right-to-left
+An operator is the most basic action that can be taken to evaluate values in a
+script. An expression is one-to-many consecutive operations. Precedence is the
+order in which an operator will be evaluated relative to another operator.
+Associativity is the direction within an expression in which a specific operator
+is evaluated. The following table lists all available operators:
+
+[cols="<6,<3,^3,^2,^4"]
+|====
+| *Operator* | *Category* | *Symbol(s)* | *Precedence* | *Associativity*
+| <> | <> | () | 0 | left -> right
+| <> | <> | . () | 1 | left -> right
+| <> | <> | . | 1 | left -> right
+| <> | <> | ?. | 1 | left -> right
+| <> | <> | () | 1 | left -> right
+| <> | <> | [] {} | 1 | left -> right
+| <> | <> | [] | 1 | left -> right
+| <> | <> | . | 1 | left -> right
+| <> | <> | [] | 1 | left -> right
+| <> | <> | [] | 1 | left -> right
+| <> | <> | [:] | 1 | left -> right
+| <> | <> | [] | 1 | left -> right
+| <> | <> | ++ | 1 | left -> right
+| <> | <> | -- | 1 | left -> right
+| <> | <> | ++ | 2 | right -> left
+| <> | <> | -- | 2 | right -> left
+| <> | <> | + | 2 | right -> left
+| <> | <