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 c918119f45d..0dda3687bb3 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 @@ -103,7 +103,7 @@ public class TransportValidateQueryAction extends TransportBroadcastOperationAct protected GroupShardsIterator shards(ClusterState clusterState, ValidateQueryRequest request, String[] concreteIndices) { // Hard-code routing to limit request to a single shard, but still, randomize it... Map> routingMap = clusterState.metaData().resolveSearchRouting(Integer.toString(ThreadLocalRandom.current().nextInt(1000)), request.indices()); - return clusterService.operationRouting().searchShards(clusterState, request.indices(), concreteIndices, null, routingMap, "_local"); + return clusterService.operationRouting().searchShards(clusterState, request.indices(), concreteIndices, routingMap, "_local"); } @Override diff --git a/src/main/java/org/elasticsearch/action/count/CountRequest.java b/src/main/java/org/elasticsearch/action/count/CountRequest.java index e47545f746e..c85ef0612c3 100644 --- a/src/main/java/org/elasticsearch/action/count/CountRequest.java +++ b/src/main/java/org/elasticsearch/action/count/CountRequest.java @@ -59,8 +59,6 @@ public class CountRequest extends BroadcastOperationRequest { private float minScore = DEFAULT_MIN_SCORE; - @Nullable - protected String queryHint; @Nullable protected String routing; @@ -78,7 +76,6 @@ public class CountRequest extends BroadcastOperationRequest { */ public CountRequest(String... indices) { super(indices); - this.queryHint = null; } @Override @@ -87,10 +84,6 @@ public class CountRequest extends BroadcastOperationRequest { return validationException; } - public String queryHint() { - return queryHint; - } - @Override protected void beforeStart() { if (querySourceUnsafe) { @@ -99,14 +92,6 @@ public class CountRequest extends BroadcastOperationRequest { } } - /** - * A query hint to optionally later be used when routing the request. - */ - public CountRequest queryHint(String queryHint) { - this.queryHint = queryHint; - return this; - } - /** * The minimum score of the documents to include in the count. */ @@ -239,50 +224,19 @@ public class CountRequest extends BroadcastOperationRequest { public void readFrom(StreamInput in) throws IOException { super.readFrom(in); minScore = in.readFloat(); - - if (in.readBoolean()) { - queryHint = in.readUTF(); - } - if (in.readBoolean()) { - routing = in.readUTF(); - } - + routing = in.readOptionalString(); querySourceUnsafe = false; querySource = in.readBytesReference(); - - int typesSize = in.readVInt(); - if (typesSize > 0) { - types = new String[typesSize]; - for (int i = 0; i < typesSize; i++) { - types[i] = in.readUTF(); - } - } + types = in.readStringArray(); } @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeFloat(minScore); - - if (queryHint == null) { - out.writeBoolean(false); - } else { - out.writeBoolean(true); - out.writeUTF(queryHint); - } - if (routing == null) { - out.writeBoolean(false); - } else { - out.writeBoolean(true); - out.writeUTF(routing); - } - + out.writeOptionalString(routing); out.writeBytesReference(querySource); - - out.writeVInt(types.length); - for (String type : types) { - out.writeUTF(type); - } + out.writeStringArray(types); } @Override diff --git a/src/main/java/org/elasticsearch/action/count/CountRequestBuilder.java b/src/main/java/org/elasticsearch/action/count/CountRequestBuilder.java index 3a4f45f533e..83271b1177b 100644 --- a/src/main/java/org/elasticsearch/action/count/CountRequestBuilder.java +++ b/src/main/java/org/elasticsearch/action/count/CountRequestBuilder.java @@ -52,14 +52,6 @@ public class CountRequestBuilder extends BroadcastOperationRequestBuilder> routingMap = clusterState.metaData().resolveSearchRouting(request.routing(), request.indices()); - return clusterService.operationRouting().searchShards(clusterState, request.indices(), concreteIndices, request.queryHint(), routingMap, null); + return clusterService.operationRouting().searchShards(clusterState, request.indices(), concreteIndices, routingMap, null); } @Override diff --git a/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java b/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java index 60ead9040b9..78dceea660e 100644 --- a/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java +++ b/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java @@ -121,8 +121,6 @@ public class MultiSearchRequest extends ActionRequest { searchRequest.preference(parser.text()); } else if ("routing".equals(currentFieldName)) { searchRequest.routing(parser.text()); - } else if ("query_hint".equals(currentFieldName) || "queryHint".equals(currentFieldName)) { - searchRequest.queryHint(parser.text()); } else if ("ignore_indices".equals(currentFieldName) || "ignoreIndices".equals(currentFieldName)) { searchRequest.ignoreIndices(IgnoreIndices.fromString(parser.text())); } diff --git a/src/main/java/org/elasticsearch/action/search/SearchRequest.java b/src/main/java/org/elasticsearch/action/search/SearchRequest.java index 2ac914b8121..9306c56cab4 100644 --- a/src/main/java/org/elasticsearch/action/search/SearchRequest.java +++ b/src/main/java/org/elasticsearch/action/search/SearchRequest.java @@ -64,8 +64,6 @@ public class SearchRequest extends ActionRequest { private String[] indices; - @Nullable - private String queryHint; @Nullable private String routing; @Nullable @@ -409,21 +407,6 @@ public class SearchRequest extends ActionRequest { return indices; } - /** - * A query hint to optionally later be used when routing the request. - */ - public SearchRequest queryHint(String queryHint) { - this.queryHint = queryHint; - return this; - } - - /** - * A query hint to optionally later be used when routing the request. - */ - public String queryHint() { - return queryHint; - } - /** * If set, will enable scrolling of the search request. */ @@ -464,7 +447,6 @@ public class SearchRequest extends ActionRequest { indices[i] = in.readString(); } - queryHint = in.readOptionalString(); routing = in.readOptionalString(); preference = in.readOptionalString(); @@ -493,7 +475,6 @@ public class SearchRequest extends ActionRequest { out.writeString(index); } - out.writeOptionalString(queryHint); out.writeOptionalString(routing); out.writeOptionalString(preference); diff --git a/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java b/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java index 922a21af6ee..6673f5e811c 100644 --- a/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java +++ b/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java @@ -126,14 +126,6 @@ public class SearchRequestBuilder extends ActionRequestBuilder> routingMap = clusterState.metaData().resolveSearchRouting(searchRequest.routing(), searchRequest.indices()); - int shardCount = clusterService.operationRouting().searchShardsCount(clusterState, searchRequest.indices(), concreteIndices, searchRequest.queryHint(), routingMap, searchRequest.preference()); + int shardCount = clusterService.operationRouting().searchShardsCount(clusterState, searchRequest.indices(), concreteIndices, routingMap, searchRequest.preference()); if (shardCount == 1) { // if we only have one group, then we always want Q_A_F, no need for DFS, and no need to do THEN since we hit one shard searchRequest.searchType(QUERY_AND_FETCH); diff --git a/src/main/java/org/elasticsearch/action/search/type/TransportSearchTypeAction.java b/src/main/java/org/elasticsearch/action/search/type/TransportSearchTypeAction.java index 38db8dc2a85..26934f71674 100644 --- a/src/main/java/org/elasticsearch/action/search/type/TransportSearchTypeAction.java +++ b/src/main/java/org/elasticsearch/action/search/type/TransportSearchTypeAction.java @@ -116,7 +116,7 @@ public abstract class TransportSearchTypeAction extends TransportAction> routingMap = clusterState.metaData().resolveSearchRouting(request.routing(), request.indices()); - shardsIts = clusterService.operationRouting().searchShards(clusterState, request.indices(), concreteIndices, request.queryHint(), routingMap, request.preference()); + shardsIts = clusterService.operationRouting().searchShards(clusterState, request.indices(), concreteIndices, routingMap, request.preference()); expectedSuccessfulOps = shardsIts.size(); // we need to add 1 for non active partition, since we count it in the total! expectedTotalOps = shardsIts.totalSizeWith1ForEmpty(); diff --git a/src/main/java/org/elasticsearch/cluster/routing/operation/OperationRouting.java b/src/main/java/org/elasticsearch/cluster/routing/operation/OperationRouting.java index 1c7d375fdbd..349bd22e458 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/operation/OperationRouting.java +++ b/src/main/java/org/elasticsearch/cluster/routing/operation/OperationRouting.java @@ -46,7 +46,7 @@ public interface OperationRouting { GroupShardsIterator deleteByQueryShards(ClusterState clusterState, String index, @Nullable Set routing) throws IndexMissingException; - int searchShardsCount(ClusterState clusterState, String[] indices, String[] concreteIndices, @Nullable String queryHint, @Nullable Map> routing, @Nullable String preference) throws IndexMissingException; + int searchShardsCount(ClusterState clusterState, String[] indices, String[] concreteIndices, @Nullable Map> routing, @Nullable String preference) throws IndexMissingException; - GroupShardsIterator searchShards(ClusterState clusterState, String[] indices, String[] concreteIndices, @Nullable String queryHint, @Nullable Map> routing, @Nullable String preference) throws IndexMissingException; + GroupShardsIterator searchShards(ClusterState clusterState, String[] indices, String[] concreteIndices, @Nullable Map> routing, @Nullable String preference) throws IndexMissingException; } diff --git a/src/main/java/org/elasticsearch/cluster/routing/operation/plain/PlainOperationRouting.java b/src/main/java/org/elasticsearch/cluster/routing/operation/plain/PlainOperationRouting.java index 39f9d3e2d8f..9bf5b7114d9 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/operation/plain/PlainOperationRouting.java +++ b/src/main/java/org/elasticsearch/cluster/routing/operation/plain/PlainOperationRouting.java @@ -111,7 +111,7 @@ public class PlainOperationRouting extends AbstractComponent implements Operatio } @Override - public int searchShardsCount(ClusterState clusterState, String[] indices, String[] concreteIndices, @Nullable String queryHint, @Nullable Map> routing, @Nullable String preference) throws IndexMissingException { + public int searchShardsCount(ClusterState clusterState, String[] indices, String[] concreteIndices, @Nullable Map> routing, @Nullable String preference) throws IndexMissingException { if (concreteIndices == null || concreteIndices.length == 0) { concreteIndices = clusterState.metaData().concreteAllOpenIndices(); } @@ -145,7 +145,7 @@ public class PlainOperationRouting extends AbstractComponent implements Operatio } @Override - public GroupShardsIterator searchShards(ClusterState clusterState, String[] indices, String[] concreteIndices, @Nullable String queryHint, @Nullable Map> routing, @Nullable String preference) throws IndexMissingException { + public GroupShardsIterator searchShards(ClusterState clusterState, String[] indices, String[] concreteIndices, @Nullable Map> routing, @Nullable String preference) throws IndexMissingException { if (concreteIndices == null || concreteIndices.length == 0) { concreteIndices = clusterState.metaData().concreteAllOpenIndices(); } diff --git a/src/main/java/org/elasticsearch/rest/action/count/RestCountAction.java b/src/main/java/org/elasticsearch/rest/action/count/RestCountAction.java index 5d3aa8099f5..182837abf8e 100644 --- a/src/main/java/org/elasticsearch/rest/action/count/RestCountAction.java +++ b/src/main/java/org/elasticsearch/rest/action/count/RestCountAction.java @@ -86,7 +86,6 @@ public class RestCountAction extends BaseRestHandler { } } } - countRequest.queryHint(request.param("query_hint")); countRequest.routing(request.param("routing")); countRequest.minScore(request.paramAsFloat("min_score", DEFAULT_MIN_SCORE)); countRequest.types(splitTypes(request.param("type"))); diff --git a/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java b/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java index ac3aede4a41..18d8dbb4862 100644 --- a/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java +++ b/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java @@ -139,7 +139,6 @@ public class RestSearchAction extends BaseRestHandler { } searchRequest.types(RestActions.splitTypes(request.param("type"))); - searchRequest.queryHint(request.param("query_hint")); searchRequest.routing(request.param("routing")); searchRequest.preference(request.param("preference")); if (request.hasParam("ignore_indices")) { diff --git a/src/test/java/org/elasticsearch/test/unit/cluster/structure/RoutingIteratorTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/structure/RoutingIteratorTests.java index a6985b2f7c3..9ccc0c33e58 100644 --- a/src/test/java/org/elasticsearch/test/unit/cluster/structure/RoutingIteratorTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/structure/RoutingIteratorTests.java @@ -333,31 +333,31 @@ public class RoutingIteratorTests { PlainOperationRouting operationRouting = new PlainOperationRouting(ImmutableSettings.Builder.EMPTY_SETTINGS, new DjbHashFunction(), new AwarenessAllocationDecider()); - GroupShardsIterator shardIterators = operationRouting.searchShards(clusterState, new String[]{"test"}, new String[]{"test"}, null, null, "_shards:0"); + GroupShardsIterator shardIterators = operationRouting.searchShards(clusterState, new String[]{"test"}, new String[]{"test"}, null, "_shards:0"); assertThat(shardIterators.size(), equalTo(1)); assertThat(shardIterators.iterator().next().shardId().id(), equalTo(0)); - shardIterators = operationRouting.searchShards(clusterState, new String[]{"test"}, new String[]{"test"}, null, null, "_shards:1"); + shardIterators = operationRouting.searchShards(clusterState, new String[]{"test"}, new String[]{"test"}, null, "_shards:1"); assertThat(shardIterators.size(), equalTo(1)); assertThat(shardIterators.iterator().next().shardId().id(), equalTo(1)); //check node preference, first without preference to see they switch - shardIterators = operationRouting.searchShards(clusterState, new String[]{"test"}, new String[]{"test"}, null, null, "_shards:0;"); + shardIterators = operationRouting.searchShards(clusterState, new String[]{"test"}, new String[]{"test"}, null, "_shards:0;"); assertThat(shardIterators.size(), equalTo(1)); assertThat(shardIterators.iterator().next().shardId().id(), equalTo(0)); String firstRoundNodeId = shardIterators.iterator().next().nextOrNull().currentNodeId(); - shardIterators = operationRouting.searchShards(clusterState, new String[]{"test"}, new String[]{"test"}, null, null, "_shards:0"); + shardIterators = operationRouting.searchShards(clusterState, new String[]{"test"}, new String[]{"test"}, null, "_shards:0"); assertThat(shardIterators.size(), equalTo(1)); assertThat(shardIterators.iterator().next().shardId().id(), equalTo(0)); assertThat(shardIterators.iterator().next().nextOrNull().currentNodeId(), not(equalTo(firstRoundNodeId))); - shardIterators = operationRouting.searchShards(clusterState, new String[]{"test"}, new String[]{"test"}, null, null, "_shards:0;_prefer_node:node1"); + shardIterators = operationRouting.searchShards(clusterState, new String[]{"test"}, new String[]{"test"}, null, "_shards:0;_prefer_node:node1"); assertThat(shardIterators.size(), equalTo(1)); assertThat(shardIterators.iterator().next().shardId().id(), equalTo(0)); assertThat(shardIterators.iterator().next().nextOrNull().currentNodeId(), equalTo("node1")); - shardIterators = operationRouting.searchShards(clusterState, new String[]{"test"}, new String[]{"test"}, null, null, "_shards:0;_prefer_node:node1"); + shardIterators = operationRouting.searchShards(clusterState, new String[]{"test"}, new String[]{"test"}, null, "_shards:0;_prefer_node:node1"); assertThat(shardIterators.size(), equalTo(1)); assertThat(shardIterators.iterator().next().shardId().id(), equalTo(0)); assertThat(shardIterators.iterator().next().nextOrNull().currentNodeId(), equalTo("node1"));