diff --git a/src/main/java/org/elasticsearch/action/TransportActions.java b/src/main/java/org/elasticsearch/action/TransportActions.java index f3826e17405..a0c7ab46851 100644 --- a/src/main/java/org/elasticsearch/action/TransportActions.java +++ b/src/main/java/org/elasticsearch/action/TransportActions.java @@ -29,8 +29,6 @@ public class TransportActions { public static final String INDEX = "indices/index/shard/index"; public static final String COUNT = "indices/count"; - - public static final String VALIDATE = "indices/validate"; public static final String DELETE = "indices/index/shard/delete"; @@ -69,6 +67,7 @@ public class TransportActions { public static final String ANALYZE = "indices/analyze"; public static final String PUT_INDEX_TEMPLATE = "indices/putIndexTemplate"; public static final String DELETE_INDEX_TEMPLATE = "indices/deleteIndexTemplate"; + public static final String VALIDATE_QUERY = "indices/validateQuery"; public static class Gateway { public static final String SNAPSHOT = "indices/gateway/snapshot"; diff --git a/src/main/java/org/elasticsearch/action/validate/ShardValidateRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ShardValidateQueryRequest.java similarity index 91% rename from src/main/java/org/elasticsearch/action/validate/ShardValidateRequest.java rename to src/main/java/org/elasticsearch/action/admin/indices/validate/query/ShardValidateQueryRequest.java index d275a43c706..6978bbbb1f8 100644 --- a/src/main/java/org/elasticsearch/action/validate/ShardValidateRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ShardValidateQueryRequest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.action.validate; +package org.elasticsearch.action.admin.indices.validate.query; import org.elasticsearch.action.support.broadcast.BroadcastShardOperationRequest; import org.elasticsearch.common.Nullable; @@ -32,7 +32,7 @@ import java.io.IOException; * * */ -class ShardValidateRequest extends BroadcastShardOperationRequest { +class ShardValidateQueryRequest extends BroadcastShardOperationRequest { private byte[] querySource; private int querySourceOffset; @@ -43,11 +43,11 @@ class ShardValidateRequest extends BroadcastShardOperationRequest { @Nullable private String[] filteringAliases; - ShardValidateRequest() { + ShardValidateQueryRequest() { } - public ShardValidateRequest(String index, int shardId, @Nullable String[] filteringAliases, ValidateRequest request) { + public ShardValidateQueryRequest(String index, int shardId, @Nullable String[] filteringAliases, ValidateQueryRequest request) { super(index, shardId); this.querySource = request.querySource(); this.querySourceOffset = request.querySourceOffset(); diff --git a/src/main/java/org/elasticsearch/action/validate/ShardValidateResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ShardValidateQueryResponse.java similarity index 86% rename from src/main/java/org/elasticsearch/action/validate/ShardValidateResponse.java rename to src/main/java/org/elasticsearch/action/admin/indices/validate/query/ShardValidateQueryResponse.java index 31b16cddcc7..e1f00448bc7 100644 --- a/src/main/java/org/elasticsearch/action/validate/ShardValidateResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ShardValidateQueryResponse.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.action.validate; +package org.elasticsearch.action.admin.indices.validate.query; import org.elasticsearch.action.support.broadcast.BroadcastShardOperationResponse; import org.elasticsearch.common.io.stream.StreamInput; @@ -30,15 +30,15 @@ import java.io.IOException; * * */ -class ShardValidateResponse extends BroadcastShardOperationResponse { +class ShardValidateQueryResponse extends BroadcastShardOperationResponse { private boolean valid; - ShardValidateResponse() { + ShardValidateQueryResponse() { } - public ShardValidateResponse(String index, int shardId, boolean valid) { + public ShardValidateQueryResponse(String index, int shardId, boolean valid) { super(index, shardId); this.valid = valid; } diff --git a/src/main/java/org/elasticsearch/action/validate/TransportValidateAction.java b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java similarity index 60% rename from src/main/java/org/elasticsearch/action/validate/TransportValidateAction.java rename to src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java index 3a91535d034..6ffd48c8275 100644 --- a/src/main/java/org/elasticsearch/action/validate/TransportValidateAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.action.validate; +package org.elasticsearch.action.admin.indices.validate.query; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.ShardOperationFailedException; @@ -32,6 +32,8 @@ import org.elasticsearch.cluster.routing.GroupShardsIterator; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.index.query.IndexQueryParserService; +import org.elasticsearch.index.query.QueryParsingException; import org.elasticsearch.index.shard.service.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; @@ -47,12 +49,12 @@ import static com.google.common.collect.Lists.newArrayList; /** * */ -public class TransportValidateAction extends TransportBroadcastOperationAction { +public class TransportValidateQueryAction extends TransportBroadcastOperationAction { private final IndicesService indicesService; @Inject - public TransportValidateAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, IndicesService indicesService) { + public TransportValidateQueryAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, IndicesService indicesService) { super(settings, threadPool, clusterService, transportService); this.indicesService = indicesService; } @@ -64,51 +66,51 @@ public class TransportValidateAction extends TransportBroadcastOperationAction> routingMap = clusterState.metaData().resolveSearchRouting("0", request.indices()); return clusterService.operationRouting().searchShards(clusterState, request.indices(), concreteIndices, null, routingMap, "_local"); } @Override - protected void checkBlock(ValidateRequest request, String[] concreteIndices, ClusterState state) { + protected void checkBlock(ValidateQueryRequest request, String[] concreteIndices, ClusterState state) { for (String index : concreteIndices) { state.blocks().indexBlocked(ClusterBlockLevel.READ, index); } } @Override - protected ValidateResponse newResponse(ValidateRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { + protected ValidateQueryResponse newResponse(ValidateQueryRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { int successfulShards = 0; int failedShards = 0; boolean valid = true; @@ -124,18 +126,29 @@ public class TransportValidateAction extends TransportBroadcastOperationAction shardFailures) { + ValidateQueryResponse(boolean valid, int totalShards, int successfulShards, int failedShards, List shardFailures) { super(totalShards, successfulShards, failedShards, shardFailures); this.valid = valid; } diff --git a/src/main/java/org/elasticsearch/action/validate/pacakge-info.java b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/package-info.java similarity index 93% rename from src/main/java/org/elasticsearch/action/validate/pacakge-info.java rename to src/main/java/org/elasticsearch/action/admin/indices/validate/query/package-info.java index a6fcb8f9a49..9ed901aaaf3 100644 --- a/src/main/java/org/elasticsearch/action/validate/pacakge-info.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/package-info.java @@ -20,4 +20,4 @@ /** * Validate action. */ -package org.elasticsearch.action.validate; \ No newline at end of file +package org.elasticsearch.action.admin.indices.validate.query; \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/Client.java b/src/main/java/org/elasticsearch/client/Client.java index 3af762d8e9a..18050ca8aa1 100644 --- a/src/main/java/org/elasticsearch/client/Client.java +++ b/src/main/java/org/elasticsearch/client/Client.java @@ -41,8 +41,6 @@ import org.elasticsearch.action.percolate.PercolateResponse; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchScrollRequest; -import org.elasticsearch.action.validate.ValidateRequest; -import org.elasticsearch.action.validate.ValidateResponse; import org.elasticsearch.client.action.bulk.BulkRequestBuilder; import org.elasticsearch.client.action.count.CountRequestBuilder; import org.elasticsearch.client.action.delete.DeleteRequestBuilder; @@ -54,7 +52,6 @@ import org.elasticsearch.client.action.mlt.MoreLikeThisRequestBuilder; import org.elasticsearch.client.action.percolate.PercolateRequestBuilder; import org.elasticsearch.client.action.search.SearchRequestBuilder; import org.elasticsearch.client.action.search.SearchScrollRequestBuilder; -import org.elasticsearch.client.action.validate.ValidateRequestBuilder; import org.elasticsearch.common.Nullable; /** @@ -277,29 +274,6 @@ public interface Client { */ CountRequestBuilder prepareCount(String... indices); - /** - * A count of all the documents matching a specific query. - * - * @param request The count request - * @return The result future - * @see Requests#countRequest(String...) - */ - ActionFuture validate(ValidateRequest request); - - /** - * A count of all the documents matching a specific query. - * - * @param request The count request - * @param listener A listener to be notified of the result - * @see Requests#countRequest(String...) - */ - void validate(ValidateRequest request, ActionListener listener); - - /** - * A count of all the documents matching a specific query. - */ - ValidateRequestBuilder prepareValidate(String... indices); - /** * Search across one or more indices and one or more types with a query. * diff --git a/src/main/java/org/elasticsearch/client/IndicesAdminClient.java b/src/main/java/org/elasticsearch/client/IndicesAdminClient.java index 6dd1d5c0e4e..323de8a8a8a 100644 --- a/src/main/java/org/elasticsearch/client/IndicesAdminClient.java +++ b/src/main/java/org/elasticsearch/client/IndicesAdminClient.java @@ -61,6 +61,8 @@ import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplat import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateResponse; import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse; +import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequest; +import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryResponse; import org.elasticsearch.client.action.admin.indices.alias.IndicesAliasesRequestBuilder; import org.elasticsearch.client.action.admin.indices.analyze.AnalyzeRequestBuilder; import org.elasticsearch.client.action.admin.indices.cache.clear.ClearIndicesCacheRequestBuilder; @@ -81,6 +83,7 @@ import org.elasticsearch.client.action.admin.indices.stats.IndicesStatsRequestBu import org.elasticsearch.client.action.admin.indices.status.IndicesStatusRequestBuilder; import org.elasticsearch.client.action.admin.indices.template.delete.DeleteIndexTemplateRequestBuilder; import org.elasticsearch.client.action.admin.indices.template.put.PutIndexTemplateRequestBuilder; +import org.elasticsearch.client.action.admin.indices.validate.query.ValidateQueryRequestBuilder; import org.elasticsearch.common.Nullable; /** @@ -537,4 +540,27 @@ public interface IndicesAdminClient { * @param name The name of the template. */ DeleteIndexTemplateRequestBuilder prepareDeleteTemplate(String name); + + /** + * Validate a query for correctness. + * + * @param request The count request + * @return The result future + * @see Requests#countRequest(String...) + */ + ActionFuture validateQuery(ValidateQueryRequest request); + + /** + * Validate a query for correctness. + * + * @param request The count request + * @param listener A listener to be notified of the result + * @see Requests#countRequest(String...) + */ + void validateQuery(ValidateQueryRequest request, ActionListener listener); + + /** + * Validate a query for correctness. + */ + ValidateQueryRequestBuilder prepareValidateQuery(String... indices); } diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/validate/query/ValidateQueryRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/validate/query/ValidateQueryRequestBuilder.java new file mode 100644 index 00000000000..65c3399a2af --- /dev/null +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/validate/query/ValidateQueryRequestBuilder.java @@ -0,0 +1,75 @@ +package org.elasticsearch.client.action.admin.indices.validate.query; + +import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequest; +import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryResponse; +import org.elasticsearch.action.support.broadcast.BroadcastOperationThreading; +import org.elasticsearch.client.IndicesAdminClient; +import org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder; +import org.elasticsearch.index.query.QueryBuilder; + +/** + * + */ +public class ValidateQueryRequestBuilder extends BaseIndicesRequestBuilder { + public ValidateQueryRequestBuilder(IndicesAdminClient client) { + super(client, new ValidateQueryRequest()); + } + + /** + * Sets the indices the query validation will run against. + */ + public ValidateQueryRequestBuilder setIndices(String... indices) { + request.indices(indices); + return this; + } + + /** + * The types of documents the query will run against. Defaults to all types. + */ + public ValidateQueryRequestBuilder setTypes(String... types) { + request.types(types); + return this; + } + + /** + * The query source to validate. + * + * @see org.elasticsearch.index.query.QueryBuilders + */ + public ValidateQueryRequestBuilder setQuery(QueryBuilder queryBuilder) { + request.query(queryBuilder); + return this; + } + + /** + * The query source to validate. + * + * @see org.elasticsearch.index.query.QueryBuilders + */ + public ValidateQueryRequestBuilder setQuery(byte[] querySource) { + request.query(querySource); + return this; + } + + /** + * Controls the operation threading model. + */ + public ValidateQueryRequestBuilder setOperationThreading(BroadcastOperationThreading operationThreading) { + request.operationThreading(operationThreading); + return this; + } + + /** + * Should the listener be called on a separate thread if needed. + */ + public ValidateQueryRequestBuilder setListenerThreaded(boolean threadedListener) { + request.listenerThreaded(threadedListener); + return this; + } + + @Override + protected void doExecute(ActionListener listener) { + client.validateQuery(request, listener); + } +} diff --git a/src/main/java/org/elasticsearch/client/action/validate/ValidateRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/validate/ValidateRequestBuilder.java deleted file mode 100644 index 57c2a7cdf43..00000000000 --- a/src/main/java/org/elasticsearch/client/action/validate/ValidateRequestBuilder.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.elasticsearch.client.action.validate; - -import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.support.broadcast.BroadcastOperationThreading; -import org.elasticsearch.action.validate.ValidateRequest; -import org.elasticsearch.action.validate.ValidateResponse; -import org.elasticsearch.client.Client; -import org.elasticsearch.client.action.support.BaseRequestBuilder; -import org.elasticsearch.index.query.QueryBuilder; - -/** - * - */ -public class ValidateRequestBuilder extends BaseRequestBuilder { - public ValidateRequestBuilder(Client client) { - super(client, new ValidateRequest()); - } - - /** - * Sets the indices the query validation will run against. - */ - public ValidateRequestBuilder setIndices(String... indices) { - request.indices(indices); - return this; - } - - /** - * The types of documents the query will run against. Defaults to all types. - */ - public ValidateRequestBuilder setTypes(String... types) { - request.types(types); - return this; - } - - /** - * The query source to validate. - * - * @see org.elasticsearch.index.query.QueryBuilders - */ - public ValidateRequestBuilder setQuery(QueryBuilder queryBuilder) { - request.query(queryBuilder); - return this; - } - - /** - * The query source to validate. - * - * @see org.elasticsearch.index.query.QueryBuilders - */ - public ValidateRequestBuilder setQuery(byte[] querySource) { - request.query(querySource); - return this; - } - - /** - * Controls the operation threading model. - */ - public ValidateRequestBuilder setOperationThreading(BroadcastOperationThreading operationThreading) { - request.operationThreading(operationThreading); - return this; - } - - /** - * Should the listener be called on a separate thread if needed. - */ - public ValidateRequestBuilder setListenerThreaded(boolean threadedListener) { - request.listenerThreaded(threadedListener); - return this; - } - - @Override - protected void doExecute(ActionListener listener) { - client.validate(request, listener); - } -} diff --git a/src/main/java/org/elasticsearch/client/node/NodeClient.java b/src/main/java/org/elasticsearch/client/node/NodeClient.java index 9fb4acd4789..74812963a95 100644 --- a/src/main/java/org/elasticsearch/client/node/NodeClient.java +++ b/src/main/java/org/elasticsearch/client/node/NodeClient.java @@ -43,11 +43,7 @@ import org.elasticsearch.action.percolate.PercolateRequest; import org.elasticsearch.action.percolate.PercolateResponse; import org.elasticsearch.action.percolate.TransportPercolateAction; import org.elasticsearch.action.search.*; -import org.elasticsearch.action.validate.TransportValidateAction; -import org.elasticsearch.action.validate.ValidateRequest; -import org.elasticsearch.action.validate.ValidateResponse; import org.elasticsearch.client.AdminClient; -import org.elasticsearch.client.action.validate.ValidateRequestBuilder; import org.elasticsearch.client.internal.InternalClient; import org.elasticsearch.client.support.AbstractClient; import org.elasticsearch.common.inject.Inject; @@ -77,8 +73,6 @@ public class NodeClient extends AbstractClient implements InternalClient { private final TransportCountAction countAction; - private final TransportValidateAction validateAction; - private final TransportSearchAction searchAction; private final TransportSearchScrollAction searchScrollAction; @@ -91,7 +85,7 @@ public class NodeClient extends AbstractClient implements InternalClient { public NodeClient(Settings settings, ThreadPool threadPool, NodeAdminClient admin, TransportIndexAction indexAction, TransportDeleteAction deleteAction, TransportBulkAction bulkAction, TransportDeleteByQueryAction deleteByQueryAction, TransportGetAction getAction, TransportMultiGetAction multiGetAction, TransportCountAction countAction, - TransportSearchAction searchAction, TransportValidateAction validateAction, TransportSearchScrollAction searchScrollAction, + TransportSearchAction searchAction, TransportSearchScrollAction searchScrollAction, TransportMoreLikeThisAction moreLikeThisAction, TransportPercolateAction percolateAction) { this.threadPool = threadPool; this.admin = admin; @@ -102,7 +96,6 @@ public class NodeClient extends AbstractClient implements InternalClient { this.getAction = getAction; this.multiGetAction = multiGetAction; this.countAction = countAction; - this.validateAction = validateAction; this.searchAction = searchAction; this.searchScrollAction = searchScrollAction; this.moreLikeThisAction = moreLikeThisAction; @@ -194,16 +187,6 @@ public class NodeClient extends AbstractClient implements InternalClient { countAction.execute(request, listener); } - @Override - public ActionFuture validate(ValidateRequest request) { - return validateAction.execute(request); - } - - @Override - public void validate(ValidateRequest request, ActionListener listener) { - validateAction.execute(request, listener); - } - @Override public ActionFuture search(SearchRequest request) { return searchAction.execute(request); diff --git a/src/main/java/org/elasticsearch/client/node/NodeIndicesAdminClient.java b/src/main/java/org/elasticsearch/client/node/NodeIndicesAdminClient.java index 8326fdc518f..a0953a22a55 100644 --- a/src/main/java/org/elasticsearch/client/node/NodeIndicesAdminClient.java +++ b/src/main/java/org/elasticsearch/client/node/NodeIndicesAdminClient.java @@ -81,6 +81,9 @@ import org.elasticsearch.action.admin.indices.template.delete.TransportDeleteInd import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse; import org.elasticsearch.action.admin.indices.template.put.TransportPutIndexTemplateAction; +import org.elasticsearch.action.admin.indices.validate.query.TransportValidateQueryAction; +import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequest; +import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryResponse; import org.elasticsearch.client.IndicesAdminClient; import org.elasticsearch.client.support.AbstractIndicesAdminClient; import org.elasticsearch.common.inject.Inject; @@ -134,6 +137,8 @@ public class NodeIndicesAdminClient extends AbstractIndicesAdminClient implement private final TransportDeleteIndexTemplateAction deleteIndexTemplateAction; + private final TransportValidateQueryAction validateQueryAction; + @Inject public NodeIndicesAdminClient(Settings settings, ThreadPool threadPool, TransportIndicesExistsAction indicesExistsAction, TransportIndicesStatsAction indicesStatsAction, TransportIndicesStatusAction indicesStatusAction, TransportIndicesSegmentsAction indicesSegmentsAction, TransportCreateIndexAction createIndexAction, TransportDeleteIndexAction deleteIndexAction, @@ -142,7 +147,7 @@ public class NodeIndicesAdminClient extends AbstractIndicesAdminClient implement TransportPutMappingAction putMappingAction, TransportDeleteMappingAction deleteMappingAction, TransportGatewaySnapshotAction gatewaySnapshotAction, TransportIndicesAliasesAction indicesAliasesAction, TransportClearIndicesCacheAction clearIndicesCacheAction, TransportUpdateSettingsAction updateSettingsAction, TransportAnalyzeAction analyzeAction, - TransportPutIndexTemplateAction putIndexTemplateAction, TransportDeleteIndexTemplateAction deleteIndexTemplateAction) { + TransportPutIndexTemplateAction putIndexTemplateAction, TransportDeleteIndexTemplateAction deleteIndexTemplateAction, TransportValidateQueryAction validateQueryAction) { this.threadPool = threadPool; this.indicesExistsAction = indicesExistsAction; this.indicesStatsAction = indicesStatsAction; @@ -164,6 +169,7 @@ public class NodeIndicesAdminClient extends AbstractIndicesAdminClient implement this.analyzeAction = analyzeAction; this.putIndexTemplateAction = putIndexTemplateAction; this.deleteIndexTemplateAction = deleteIndexTemplateAction; + this.validateQueryAction = validateQueryAction; } @Override @@ -370,4 +376,14 @@ public class NodeIndicesAdminClient extends AbstractIndicesAdminClient implement public void deleteTemplate(DeleteIndexTemplateRequest request, ActionListener listener) { deleteIndexTemplateAction.execute(request, listener); } + + @Override + public ActionFuture validateQuery(ValidateQueryRequest request) { + return validateQueryAction.execute(request); + } + + @Override + public void validateQuery(ValidateQueryRequest request, ActionListener listener) { + validateQueryAction.execute(request, listener); + } } diff --git a/src/main/java/org/elasticsearch/client/support/AbstractClient.java b/src/main/java/org/elasticsearch/client/support/AbstractClient.java index 246b848e796..38340d8f36d 100644 --- a/src/main/java/org/elasticsearch/client/support/AbstractClient.java +++ b/src/main/java/org/elasticsearch/client/support/AbstractClient.java @@ -30,7 +30,6 @@ import org.elasticsearch.client.action.mlt.MoreLikeThisRequestBuilder; import org.elasticsearch.client.action.percolate.PercolateRequestBuilder; import org.elasticsearch.client.action.search.SearchRequestBuilder; import org.elasticsearch.client.action.search.SearchScrollRequestBuilder; -import org.elasticsearch.client.action.validate.ValidateRequestBuilder; import org.elasticsearch.client.internal.InternalClient; import org.elasticsearch.common.Nullable; @@ -104,11 +103,6 @@ public abstract class AbstractClient implements InternalClient { return new CountRequestBuilder(this).setIndices(indices); } - @Override - public ValidateRequestBuilder prepareValidate(String... indices) { - return new ValidateRequestBuilder(this).setIndices(indices); - } - @Override public MoreLikeThisRequestBuilder prepareMoreLikeThis(String index, String type, String id) { return new MoreLikeThisRequestBuilder(this, index, type, id); diff --git a/src/main/java/org/elasticsearch/client/support/AbstractIndicesAdminClient.java b/src/main/java/org/elasticsearch/client/support/AbstractIndicesAdminClient.java index a2ebcb7c352..04356b9be77 100644 --- a/src/main/java/org/elasticsearch/client/support/AbstractIndicesAdminClient.java +++ b/src/main/java/org/elasticsearch/client/support/AbstractIndicesAdminClient.java @@ -39,6 +39,7 @@ import org.elasticsearch.client.action.admin.indices.stats.IndicesStatsRequestBu import org.elasticsearch.client.action.admin.indices.status.IndicesStatusRequestBuilder; import org.elasticsearch.client.action.admin.indices.template.delete.DeleteIndexTemplateRequestBuilder; import org.elasticsearch.client.action.admin.indices.template.put.PutIndexTemplateRequestBuilder; +import org.elasticsearch.client.action.admin.indices.validate.query.ValidateQueryRequestBuilder; import org.elasticsearch.client.internal.InternalIndicesAdminClient; import org.elasticsearch.common.Nullable; @@ -151,4 +152,9 @@ public abstract class AbstractIndicesAdminClient implements InternalIndicesAdmin public DeleteIndexTemplateRequestBuilder prepareDeleteTemplate(String name) { return new DeleteIndexTemplateRequestBuilder(this, name); } + + @Override + public ValidateQueryRequestBuilder prepareValidateQuery(String... indices) { + return new ValidateQueryRequestBuilder(this).setIndices(indices); + } } diff --git a/src/main/java/org/elasticsearch/client/transport/TransportClient.java b/src/main/java/org/elasticsearch/client/transport/TransportClient.java index 569b255422f..890ad1f3b38 100644 --- a/src/main/java/org/elasticsearch/client/transport/TransportClient.java +++ b/src/main/java/org/elasticsearch/client/transport/TransportClient.java @@ -43,8 +43,6 @@ import org.elasticsearch.action.percolate.PercolateResponse; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchScrollRequest; -import org.elasticsearch.action.validate.ValidateRequest; -import org.elasticsearch.action.validate.ValidateResponse; import org.elasticsearch.client.AdminClient; import org.elasticsearch.client.support.AbstractClient; import org.elasticsearch.client.transport.action.ClientTransportActionModule; @@ -321,16 +319,6 @@ public class TransportClient extends AbstractClient { internalClient.count(request, listener); } - @Override - public ActionFuture validate(ValidateRequest request) { - return internalClient.validate(request); - } - - @Override - public void validate(ValidateRequest request, ActionListener listener) { - internalClient.validate(request, listener); - } - @Override public ActionFuture search(SearchRequest request) { return internalClient.search(request); diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/validate/query/ClientTransportValidateQueryAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/validate/query/ClientTransportValidateQueryAction.java new file mode 100644 index 00000000000..1072b28c140 --- /dev/null +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/validate/query/ClientTransportValidateQueryAction.java @@ -0,0 +1,25 @@ +package org.elasticsearch.client.transport.action.admin.indices.validate.query; + +import org.elasticsearch.action.TransportActions; +import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequest; +import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryResponse; +import org.elasticsearch.client.transport.action.support.BaseClientTransportAction; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.transport.TransportService; + +/** + * + */ +public class ClientTransportValidateQueryAction extends BaseClientTransportAction { + + @Inject + public ClientTransportValidateQueryAction(Settings settings, TransportService transportService) { + super(settings, transportService, ValidateQueryResponse.class); + } + + @Override + protected String action() { + return TransportActions.Admin.Indices.VALIDATE_QUERY; + } +} diff --git a/src/main/java/org/elasticsearch/client/transport/action/validate/ClientTransportValidateAction.java b/src/main/java/org/elasticsearch/client/transport/action/validate/ClientTransportValidateAction.java deleted file mode 100644 index d449a7e673e..00000000000 --- a/src/main/java/org/elasticsearch/client/transport/action/validate/ClientTransportValidateAction.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.elasticsearch.client.transport.action.validate; - -import org.elasticsearch.action.TransportActions; -import org.elasticsearch.action.validate.ValidateRequest; -import org.elasticsearch.action.validate.ValidateResponse; -import org.elasticsearch.client.transport.action.support.BaseClientTransportAction; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.transport.TransportService; - -/** - * - */ -public class ClientTransportValidateAction extends BaseClientTransportAction { - - @Inject - public ClientTransportValidateAction(Settings settings, TransportService transportService) { - super(settings, transportService, ValidateResponse.class); - } - - @Override - protected String action() { - return TransportActions.VALIDATE; - } -} diff --git a/src/main/java/org/elasticsearch/client/transport/support/InternalTransportClient.java b/src/main/java/org/elasticsearch/client/transport/support/InternalTransportClient.java index 96868f6c500..6f9370c4c61 100644 --- a/src/main/java/org/elasticsearch/client/transport/support/InternalTransportClient.java +++ b/src/main/java/org/elasticsearch/client/transport/support/InternalTransportClient.java @@ -42,8 +42,6 @@ import org.elasticsearch.action.percolate.PercolateResponse; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchScrollRequest; -import org.elasticsearch.action.validate.ValidateRequest; -import org.elasticsearch.action.validate.ValidateResponse; import org.elasticsearch.client.AdminClient; import org.elasticsearch.client.internal.InternalClient; import org.elasticsearch.client.support.AbstractClient; @@ -59,7 +57,6 @@ import org.elasticsearch.client.transport.action.mlt.ClientTransportMoreLikeThis import org.elasticsearch.client.transport.action.percolate.ClientTransportPercolateAction; import org.elasticsearch.client.transport.action.search.ClientTransportSearchAction; import org.elasticsearch.client.transport.action.search.ClientTransportSearchScrollAction; -import org.elasticsearch.client.transport.action.validate.ClientTransportValidateAction; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -90,8 +87,6 @@ public class InternalTransportClient extends AbstractClient implements InternalC private final ClientTransportCountAction countAction; - private final ClientTransportValidateAction validateAction; - private final ClientTransportSearchAction searchAction; private final ClientTransportSearchScrollAction searchScrollAction; @@ -104,7 +99,7 @@ public class InternalTransportClient extends AbstractClient implements InternalC public InternalTransportClient(Settings settings, ThreadPool threadPool, TransportClientNodesService nodesService, InternalTransportAdminClient adminClient, ClientTransportIndexAction indexAction, ClientTransportDeleteAction deleteAction, ClientTransportBulkAction bulkAction, ClientTransportGetAction getAction, ClientTransportMultiGetAction multiGetAction, - ClientTransportDeleteByQueryAction deleteByQueryAction, ClientTransportCountAction countAction, ClientTransportValidateAction validateAction, + ClientTransportDeleteByQueryAction deleteByQueryAction, ClientTransportCountAction countAction, ClientTransportSearchAction searchAction, ClientTransportSearchScrollAction searchScrollAction, ClientTransportMoreLikeThisAction moreLikeThisAction, ClientTransportPercolateAction percolateAction) { this.threadPool = threadPool; @@ -118,7 +113,6 @@ public class InternalTransportClient extends AbstractClient implements InternalC this.multiGetAction = multiGetAction; this.deleteByQueryAction = deleteByQueryAction; this.countAction = countAction; - this.validateAction = validateAction; this.searchAction = searchAction; this.searchScrollAction = searchScrollAction; this.moreLikeThisAction = moreLikeThisAction; @@ -280,26 +274,6 @@ public class InternalTransportClient extends AbstractClient implements InternalC }, listener); } - @Override - public ActionFuture validate(final ValidateRequest request) { - return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override - public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { - return validateAction.execute(node, request); - } - }); - } - - @Override - public void validate(final ValidateRequest request, final ActionListener listener) { - nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override - public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { - validateAction.execute(node, request, listener); - } - }, listener); - } - @Override public ActionFuture search(final SearchRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { diff --git a/src/main/java/org/elasticsearch/client/transport/support/InternalTransportIndicesAdminClient.java b/src/main/java/org/elasticsearch/client/transport/support/InternalTransportIndicesAdminClient.java index 8daf3ea5aa6..12e7ce46a9e 100644 --- a/src/main/java/org/elasticsearch/client/transport/support/InternalTransportIndicesAdminClient.java +++ b/src/main/java/org/elasticsearch/client/transport/support/InternalTransportIndicesAdminClient.java @@ -62,6 +62,8 @@ import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplat import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateResponse; import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse; +import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequest; +import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryResponse; import org.elasticsearch.client.IndicesAdminClient; import org.elasticsearch.client.support.AbstractIndicesAdminClient; import org.elasticsearch.client.transport.TransportClientNodesService; @@ -85,6 +87,7 @@ import org.elasticsearch.client.transport.action.admin.indices.stats.ClientTrans import org.elasticsearch.client.transport.action.admin.indices.status.ClientTransportIndicesStatusAction; import org.elasticsearch.client.transport.action.admin.indices.template.delete.ClientTransportDeleteIndexTemplateAction; import org.elasticsearch.client.transport.action.admin.indices.template.put.ClientTransportPutIndexTemplateAction; +import org.elasticsearch.client.transport.action.admin.indices.validate.query.ClientTransportValidateQueryAction; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -139,6 +142,8 @@ public class InternalTransportIndicesAdminClient extends AbstractIndicesAdminCli private final ClientTransportDeleteIndexTemplateAction deleteIndexTemplateAction; + private final ClientTransportValidateQueryAction validateQueryAction; + @Inject public InternalTransportIndicesAdminClient(Settings settings, TransportClientNodesService nodesService, ThreadPool threadPool, ClientTransportIndicesExistsAction indicesExistsAction, ClientTransportIndicesStatusAction indicesStatusAction, ClientTransportIndicesStatsAction indicesStatsAction, ClientTransportIndicesSegmentsAction indicesSegmentsAction, @@ -147,7 +152,7 @@ public class InternalTransportIndicesAdminClient extends AbstractIndicesAdminCli ClientTransportRefreshAction refreshAction, ClientTransportFlushAction flushAction, ClientTransportOptimizeAction optimizeAction, ClientTransportPutMappingAction putMappingAction, ClientTransportDeleteMappingAction deleteMappingAction, ClientTransportGatewaySnapshotAction gatewaySnapshotAction, ClientTransportIndicesAliasesAction indicesAliasesAction, ClientTransportClearIndicesCacheAction clearIndicesCacheAction, - ClientTransportUpdateSettingsAction updateSettingsAction, ClientTransportAnalyzeAction analyzeAction, + ClientTransportUpdateSettingsAction updateSettingsAction, ClientTransportAnalyzeAction analyzeAction, ClientTransportValidateQueryAction validateQueryAction, ClientTransportPutIndexTemplateAction putIndexTemplateAction, ClientTransportDeleteIndexTemplateAction deleteIndexTemplateAction) { this.nodesService = nodesService; this.threadPool = threadPool; @@ -171,6 +176,7 @@ public class InternalTransportIndicesAdminClient extends AbstractIndicesAdminCli this.analyzeAction = analyzeAction; this.putIndexTemplateAction = putIndexTemplateAction; this.deleteIndexTemplateAction = deleteIndexTemplateAction; + this.validateQueryAction = validateQueryAction; } @Override @@ -577,4 +583,24 @@ public class InternalTransportIndicesAdminClient extends AbstractIndicesAdminCli } }, listener); } + + @Override + public ActionFuture validateQuery(final ValidateQueryRequest request) { + return nodesService.execute(new TransportClientNodesService.NodeCallback>() { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + return validateQueryAction.execute(node, request); + } + }); + } + + @Override + public void validateQuery(final ValidateQueryRequest request, final ActionListener listener) { + nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + validateQueryAction.execute(node, request, listener); + } + }, listener); + } } diff --git a/src/main/java/org/elasticsearch/index/shard/service/IndexShard.java b/src/main/java/org/elasticsearch/index/shard/service/IndexShard.java index c51b6dbe985..d39c6eb9fd1 100644 --- a/src/main/java/org/elasticsearch/index/shard/service/IndexShard.java +++ b/src/main/java/org/elasticsearch/index/shard/service/IndexShard.java @@ -105,10 +105,6 @@ public interface IndexShard extends IndexShardComponent { Engine.Searcher searcher(); - boolean validate(byte[] querySource, @Nullable String[] filteringAliases, String... types) throws ElasticSearchException; - - boolean validate(byte[] querySource, int querySourceOffset, int querySourceLength, @Nullable String[] filteringAliases, String... types) throws ElasticSearchException; - /** * Returns true if this shard can ignore a recovery attempt made to it (since the already doing/done it) */ diff --git a/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java b/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java index 9a180776d36..7a82e0d0673 100644 --- a/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java +++ b/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java @@ -51,7 +51,6 @@ import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.merge.MergeStats; import org.elasticsearch.index.merge.scheduler.MergeSchedulerProvider; import org.elasticsearch.index.query.IndexQueryParserService; -import org.elasticsearch.index.query.QueryParsingException; import org.elasticsearch.index.refresh.RefreshStats; import org.elasticsearch.index.search.stats.SearchStats; import org.elasticsearch.index.search.stats.ShardSearchService; @@ -519,28 +518,6 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I return engine.searcher(); } - @Override - public boolean validate(byte[] querySource, @Nullable String[] filteringAliases, String... types) throws ElasticSearchException { - return validate(querySource, 0, querySource.length, filteringAliases, types); - } - - @Override - public boolean validate(byte[] querySource, int querySourceOffset, int querySourceLength, @Nullable String[] filteringAliases, String... types) throws ElasticSearchException { - readAllowed(); - if (querySourceLength == 0) { - return true; - } else { - try { - queryParserService.parse(querySource, querySourceOffset, querySourceLength); - } catch (QueryParsingException e) { - return false; - } catch (AssertionError e) { - return false; - } - } - return true; - } - public void close(String reason) { synchronized (mutex) { indexSettingsService.removeListener(applyRefreshSettings); diff --git a/src/main/java/org/elasticsearch/rest/action/RestActionModule.java b/src/main/java/org/elasticsearch/rest/action/RestActionModule.java index 0c10ef62803..b007b1738a5 100644 --- a/src/main/java/org/elasticsearch/rest/action/RestActionModule.java +++ b/src/main/java/org/elasticsearch/rest/action/RestActionModule.java @@ -58,6 +58,7 @@ import org.elasticsearch.rest.action.admin.indices.status.RestIndicesStatusActio import org.elasticsearch.rest.action.admin.indices.template.delete.RestDeleteIndexTemplateAction; import org.elasticsearch.rest.action.admin.indices.template.get.RestGetIndexTemplateAction; import org.elasticsearch.rest.action.admin.indices.template.put.RestPutIndexTemplateAction; +import org.elasticsearch.rest.action.admin.indices.validate.query.RestValidateQueryAction; import org.elasticsearch.rest.action.bulk.RestBulkAction; import org.elasticsearch.rest.action.count.RestCountAction; import org.elasticsearch.rest.action.delete.RestDeleteAction; @@ -70,7 +71,6 @@ import org.elasticsearch.rest.action.mlt.RestMoreLikeThisAction; import org.elasticsearch.rest.action.percolate.RestPercolateAction; import org.elasticsearch.rest.action.search.RestSearchAction; import org.elasticsearch.rest.action.search.RestSearchScrollAction; -import org.elasticsearch.rest.action.validate.RestValidateAction; import java.util.List; @@ -151,7 +151,7 @@ public class RestActionModule extends AbstractModule { bind(RestSearchAction.class).asEagerSingleton(); bind(RestSearchScrollAction.class).asEagerSingleton(); - bind(RestValidateAction.class).asEagerSingleton(); + bind(RestValidateQueryAction.class).asEagerSingleton(); bind(RestMoreLikeThisAction.class).asEagerSingleton(); diff --git a/src/main/java/org/elasticsearch/rest/action/validate/RestValidateAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/validate/query/RestValidateQueryAction.java similarity index 74% rename from src/main/java/org/elasticsearch/rest/action/validate/RestValidateAction.java rename to src/main/java/org/elasticsearch/rest/action/admin/indices/validate/query/RestValidateQueryAction.java index 2bbac22329d..9da168c2c4c 100644 --- a/src/main/java/org/elasticsearch/rest/action/validate/RestValidateAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/validate/query/RestValidateQueryAction.java @@ -17,12 +17,12 @@ * under the License. */ -package org.elasticsearch.rest.action.validate; +package org.elasticsearch.rest.action.admin.indices.validate.query; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.broadcast.BroadcastOperationThreading; -import org.elasticsearch.action.validate.ValidateRequest; -import org.elasticsearch.action.validate.ValidateResponse; +import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequest; +import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryResponse; import org.elasticsearch.client.Client; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -43,45 +43,45 @@ import static org.elasticsearch.rest.action.support.RestActions.splitTypes; /** * */ -public class RestValidateAction extends BaseRestHandler { +public class RestValidateQueryAction extends BaseRestHandler { @Inject - public RestValidateAction(Settings settings, Client client, RestController controller) { + public RestValidateQueryAction(Settings settings, Client client, RestController controller) { super(settings, client); - controller.registerHandler(GET, "/_validate", this); - controller.registerHandler(POST, "/_validate", this); - controller.registerHandler(GET, "/{index}/_validate", this); - controller.registerHandler(POST, "/{index}/_validate", this); - controller.registerHandler(GET, "/{index}/{type}/_validate", this); - controller.registerHandler(POST, "/{index}/{type}/_validate", this); + controller.registerHandler(GET, "/_validate/query", this); + controller.registerHandler(POST, "/_validate/query", this); + controller.registerHandler(GET, "/{index}/_validate/query", this); + controller.registerHandler(POST, "/{index}/_validate/query", this); + controller.registerHandler(GET, "/{index}/{type}/_validate/query", this); + controller.registerHandler(POST, "/{index}/{type}/_validate/query", this); } @Override public void handleRequest(final RestRequest request, final RestChannel channel) { - ValidateRequest validateRequest = new ValidateRequest(RestActions.splitIndices(request.param("index"))); + ValidateQueryRequest validateQueryRequest = new ValidateQueryRequest(RestActions.splitIndices(request.param("index"))); // we just send back a response, no need to fork a listener - validateRequest.listenerThreaded(false); + validateQueryRequest.listenerThreaded(false); try { BroadcastOperationThreading operationThreading = BroadcastOperationThreading.fromString(request.param("operation_threading"), BroadcastOperationThreading.SINGLE_THREAD); if (operationThreading == BroadcastOperationThreading.NO_THREADS) { // since we don't spawn, don't allow no_threads, but change it to a single thread operationThreading = BroadcastOperationThreading.SINGLE_THREAD; } - validateRequest.operationThreading(operationThreading); + validateQueryRequest.operationThreading(operationThreading); if (request.hasContent()) { - validateRequest.query(request.contentByteArray(), request.contentByteArrayOffset(), request.contentLength(), true); + validateQueryRequest.query(request.contentByteArray(), request.contentByteArrayOffset(), request.contentLength(), true); } else { String source = request.param("source"); if (source != null) { - validateRequest.query(source); + validateQueryRequest.query(source); } else { byte[] querySource = RestActions.parseQuerySource(request); if (querySource != null) { - validateRequest.query(querySource); + validateQueryRequest.query(querySource); } } } - validateRequest.types(splitTypes(request.param("type"))); + validateQueryRequest.types(splitTypes(request.param("type"))); } catch (Exception e) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); @@ -92,9 +92,9 @@ public class RestValidateAction extends BaseRestHandler { return; } - client.validate(validateRequest, new ActionListener() { + client.admin().indices().validateQuery(validateQueryRequest, new ActionListener() { @Override - public void onResponse(ValidateResponse response) { + public void onResponse(ValidateQueryResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); diff --git a/src/test/java/org/elasticsearch/test/integration/validate/SimpleValidateTests.java b/src/test/java/org/elasticsearch/test/integration/validate/SimpleValidateQueryTests.java similarity index 68% rename from src/test/java/org/elasticsearch/test/integration/validate/SimpleValidateTests.java rename to src/test/java/org/elasticsearch/test/integration/validate/SimpleValidateQueryTests.java index b117f3abcfb..680374a183f 100644 --- a/src/test/java/org/elasticsearch/test/integration/validate/SimpleValidateTests.java +++ b/src/test/java/org/elasticsearch/test/integration/validate/SimpleValidateQueryTests.java @@ -34,7 +34,7 @@ import static org.hamcrest.Matchers.*; /** * */ -public class SimpleValidateTests extends AbstractNodesTests { +public class SimpleValidateQueryTests extends AbstractNodesTests { private Client client; @@ -70,15 +70,15 @@ public class SimpleValidateTests extends AbstractNodesTests { client.admin().indices().prepareRefresh().execute().actionGet(); - assertThat(client.prepareValidate("test").setQuery("foo".getBytes()).execute().actionGet().valid(), equalTo(false)); - assertThat(client.prepareValidate("test").setQuery(QueryBuilders.queryString("_id:1")).execute().actionGet().valid(), equalTo(true)); - assertThat(client.prepareValidate("test").setQuery(QueryBuilders.queryString("_i:d:1")).execute().actionGet().valid(), equalTo(false)); + assertThat(client.admin().indices().prepareValidateQuery("test").setQuery("foo".getBytes()).execute().actionGet().valid(), equalTo(false)); + assertThat(client.admin().indices().prepareValidateQuery("test").setQuery(QueryBuilders.queryString("_id:1")).execute().actionGet().valid(), equalTo(true)); + assertThat(client.admin().indices().prepareValidateQuery("test").setQuery(QueryBuilders.queryString("_i:d:1")).execute().actionGet().valid(), equalTo(false)); - assertThat(client.prepareValidate("test").setQuery(QueryBuilders.queryString("foo:1")).execute().actionGet().valid(), equalTo(true)); - assertThat(client.prepareValidate("test").setQuery(QueryBuilders.queryString("bar:hey")).execute().actionGet().valid(), equalTo(false)); + assertThat(client.admin().indices().prepareValidateQuery("test").setQuery(QueryBuilders.queryString("foo:1")).execute().actionGet().valid(), equalTo(true)); + assertThat(client.admin().indices().prepareValidateQuery("test").setQuery(QueryBuilders.queryString("bar:hey")).execute().actionGet().valid(), equalTo(false)); - assertThat(client.prepareValidate("test").setQuery(QueryBuilders.queryString("nonexistent:hello")).execute().actionGet().valid(), equalTo(true)); + assertThat(client.admin().indices().prepareValidateQuery("test").setQuery(QueryBuilders.queryString("nonexistent:hello")).execute().actionGet().valid(), equalTo(true)); - assertThat(client.prepareValidate("test").setQuery(QueryBuilders.queryString("foo:1 AND")).execute().actionGet().valid(), equalTo(false)); + assertThat(client.admin().indices().prepareValidateQuery("test").setQuery(QueryBuilders.queryString("foo:1 AND")).execute().actionGet().valid(), equalTo(false)); } }