diff --git a/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ShardValidateQueryRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ShardValidateQueryRequest.java index bd3c22cc303..f56fecc7db7 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ShardValidateQueryRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ShardValidateQueryRequest.java @@ -19,6 +19,7 @@ package org.elasticsearch.action.admin.indices.validate.query; +import org.elasticsearch.Version; import org.elasticsearch.action.support.broadcast.BroadcastShardOperationRequest; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; @@ -36,6 +37,7 @@ class ShardValidateQueryRequest extends BroadcastShardOperationRequest { private BytesReference querySource; private String[] types = Strings.EMPTY_ARRAY; private boolean explain; + private long nowInMillis; @Nullable private String[] filteringAliases; @@ -50,6 +52,7 @@ class ShardValidateQueryRequest extends BroadcastShardOperationRequest { this.types = request.types(); this.explain = request.explain(); this.filteringAliases = filteringAliases; + this.nowInMillis = request.nowInMillis; } public BytesReference querySource() { @@ -68,6 +71,10 @@ class ShardValidateQueryRequest extends BroadcastShardOperationRequest { return filteringAliases; } + public long nowInMillis() { + return this.nowInMillis; + } + @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); @@ -89,6 +96,12 @@ class ShardValidateQueryRequest extends BroadcastShardOperationRequest { } explain = in.readBoolean(); + + if (in.getVersion().onOrAfter(Version.V_0_90_6)) { + nowInMillis = in.readVLong(); + } else { + nowInMillis = System.currentTimeMillis(); + } } @Override @@ -110,5 +123,9 @@ class ShardValidateQueryRequest extends BroadcastShardOperationRequest { } out.writeBoolean(explain); + + if (out.getVersion().onOrAfter(Version.V_0_90_6)) { + out.writeVLong(nowInMillis); + } } } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java index 8965140389e..f38fb08a58a 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java @@ -21,6 +21,7 @@ package org.elasticsearch.action.admin.indices.validate.query; import jsr166y.ThreadLocalRandom; import org.elasticsearch.ElasticSearchException; +import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ShardOperationFailedException; import org.elasticsearch.action.support.DefaultShardOperationFailedException; import org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException; @@ -73,6 +74,12 @@ public class TransportValidateQueryAction extends TransportBroadcastOperationAct this.cacheRecycler = cacheRecycler; } + @Override + protected void doExecute(ValidateQueryRequest request, ActionListener listener) { + request.nowInMillis = System.currentTimeMillis(); + super.doExecute(request, listener); + } + @Override protected String executor() { return ThreadPool.Names.SEARCH; @@ -171,7 +178,7 @@ public class TransportValidateQueryAction extends TransportBroadcastOperationAct valid = true; } else { SearchContext.setCurrent(new DefaultSearchContext(0, - new ShardSearchRequest().types(request.types()), + new ShardSearchRequest().types(request.types()).nowInMillis(request.nowInMillis()), null, indexShard.acquireSearcher(), indexService, indexShard, scriptService, cacheRecycler)); try { diff --git a/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryRequest.java index 6c5cd7df20f..6dd0ad64030 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryRequest.java @@ -56,6 +56,8 @@ public class ValidateQueryRequest extends BroadcastOperationRequest matcher) { ValidateQueryResponse response = client().admin().indices().prepareValidateQuery("test") @@ -239,5 +267,4 @@ public class SimpleValidateQueryTests extends AbstractIntegrationTest { assertThat(response.getQueryExplanation().get(0).getExplanation(), matcher); assertThat(response.isValid(), equalTo(true)); } - }