cleanup queryHint since its not was never used
preference ended up as the way to control routing
This commit is contained in:
parent
bcdda811ef
commit
2c4b9d9ba2
|
@ -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<String, Set<String>> 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
|
||||
|
|
|
@ -59,8 +59,6 @@ public class CountRequest extends BroadcastOperationRequest<CountRequest> {
|
|||
|
||||
private float minScore = DEFAULT_MIN_SCORE;
|
||||
|
||||
@Nullable
|
||||
protected String queryHint;
|
||||
@Nullable
|
||||
protected String routing;
|
||||
|
||||
|
@ -78,7 +76,6 @@ public class CountRequest extends BroadcastOperationRequest<CountRequest> {
|
|||
*/
|
||||
public CountRequest(String... indices) {
|
||||
super(indices);
|
||||
this.queryHint = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -87,10 +84,6 @@ public class CountRequest extends BroadcastOperationRequest<CountRequest> {
|
|||
return validationException;
|
||||
}
|
||||
|
||||
public String queryHint() {
|
||||
return queryHint;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void beforeStart() {
|
||||
if (querySourceUnsafe) {
|
||||
|
@ -99,14 +92,6 @@ public class CountRequest extends BroadcastOperationRequest<CountRequest> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<CountRequest> {
|
|||
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
|
||||
|
|
|
@ -52,14 +52,6 @@ public class CountRequestBuilder extends BroadcastOperationRequestBuilder<CountR
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A query hint to optionally later be used when routing the request.
|
||||
*/
|
||||
public CountRequestBuilder setQueryHint(String queryHint) {
|
||||
request.queryHint(queryHint);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A comma separated list of routing values to control the shards the search will be executed on.
|
||||
*/
|
||||
|
|
|
@ -104,7 +104,7 @@ public class TransportCountAction extends TransportBroadcastOperationAction<Coun
|
|||
@Override
|
||||
protected GroupShardsIterator shards(ClusterState clusterState, CountRequest request, String[] concreteIndices) {
|
||||
Map<String, Set<String>> 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
|
||||
|
|
|
@ -121,8 +121,6 @@ public class MultiSearchRequest extends ActionRequest<MultiSearchRequest> {
|
|||
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()));
|
||||
}
|
||||
|
|
|
@ -64,8 +64,6 @@ public class SearchRequest extends ActionRequest<SearchRequest> {
|
|||
|
||||
private String[] indices;
|
||||
|
||||
@Nullable
|
||||
private String queryHint;
|
||||
@Nullable
|
||||
private String routing;
|
||||
@Nullable
|
||||
|
@ -409,21 +407,6 @@ public class SearchRequest extends ActionRequest<SearchRequest> {
|
|||
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<SearchRequest> {
|
|||
indices[i] = in.readString();
|
||||
}
|
||||
|
||||
queryHint = in.readOptionalString();
|
||||
routing = in.readOptionalString();
|
||||
preference = in.readOptionalString();
|
||||
|
||||
|
@ -493,7 +475,6 @@ public class SearchRequest extends ActionRequest<SearchRequest> {
|
|||
out.writeString(index);
|
||||
}
|
||||
|
||||
out.writeOptionalString(queryHint);
|
||||
out.writeOptionalString(routing);
|
||||
out.writeOptionalString(preference);
|
||||
|
||||
|
|
|
@ -126,14 +126,6 @@ public class SearchRequestBuilder extends ActionRequestBuilder<SearchRequest, Se
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A query hint to optionally later be used when routing the request.
|
||||
*/
|
||||
public SearchRequestBuilder setQueryHint(String queryHint) {
|
||||
request.queryHint(queryHint);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A comma separated list of routing values to control the shards the search will be executed on.
|
||||
*/
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.elasticsearch.action.search;
|
|||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.search.type.*;
|
||||
import org.elasticsearch.action.support.IgnoreIndices;
|
||||
import org.elasticsearch.action.support.TransportAction;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
|
@ -90,7 +89,7 @@ public class TransportSearchAction extends TransportAction<SearchRequest, Search
|
|||
ClusterState clusterState = clusterService.state();
|
||||
String[] concreteIndices = clusterState.metaData().concreteIndices(searchRequest.indices(), searchRequest.ignoreIndices(), true);
|
||||
Map<String, Set<String>> 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);
|
||||
|
|
|
@ -116,7 +116,7 @@ public abstract class TransportSearchTypeAction extends TransportAction<SearchRe
|
|||
|
||||
Map<String, Set<String>> 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();
|
||||
|
|
|
@ -46,7 +46,7 @@ public interface OperationRouting {
|
|||
|
||||
GroupShardsIterator deleteByQueryShards(ClusterState clusterState, String index, @Nullable Set<String> routing) throws IndexMissingException;
|
||||
|
||||
int searchShardsCount(ClusterState clusterState, String[] indices, String[] concreteIndices, @Nullable String queryHint, @Nullable Map<String, Set<String>> routing, @Nullable String preference) throws IndexMissingException;
|
||||
int searchShardsCount(ClusterState clusterState, String[] indices, String[] concreteIndices, @Nullable Map<String, Set<String>> routing, @Nullable String preference) throws IndexMissingException;
|
||||
|
||||
GroupShardsIterator searchShards(ClusterState clusterState, String[] indices, String[] concreteIndices, @Nullable String queryHint, @Nullable Map<String, Set<String>> routing, @Nullable String preference) throws IndexMissingException;
|
||||
GroupShardsIterator searchShards(ClusterState clusterState, String[] indices, String[] concreteIndices, @Nullable Map<String, Set<String>> routing, @Nullable String preference) throws IndexMissingException;
|
||||
}
|
||||
|
|
|
@ -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<String, Set<String>> routing, @Nullable String preference) throws IndexMissingException {
|
||||
public int searchShardsCount(ClusterState clusterState, String[] indices, String[] concreteIndices, @Nullable Map<String, Set<String>> 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<String, Set<String>> routing, @Nullable String preference) throws IndexMissingException {
|
||||
public GroupShardsIterator searchShards(ClusterState clusterState, String[] indices, String[] concreteIndices, @Nullable Map<String, Set<String>> routing, @Nullable String preference) throws IndexMissingException {
|
||||
if (concreteIndices == null || concreteIndices.length == 0) {
|
||||
concreteIndices = clusterState.metaData().concreteAllOpenIndices();
|
||||
}
|
||||
|
|
|
@ -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")));
|
||||
|
|
|
@ -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")) {
|
||||
|
|
|
@ -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"));
|
||||
|
|
Loading…
Reference in New Issue