|
@@ -19,6 +19,7 @@
|
|
|
|
|
|
package org.elasticsearch.action.admin.cluster.shards;
|
|
package org.elasticsearch.action.admin.cluster.shards;
|
|
|
|
|
|
|
|
+import org.elasticsearch.Version;
|
|
import org.elasticsearch.action.ActionRequestValidationException;
|
|
import org.elasticsearch.action.ActionRequestValidationException;
|
|
import org.elasticsearch.action.IndicesRequest;
|
|
import org.elasticsearch.action.IndicesRequest;
|
|
import org.elasticsearch.action.support.IndicesOptions;
|
|
import org.elasticsearch.action.support.IndicesOptions;
|
|
@@ -29,14 +30,15 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
public class ClusterSearchShardsRequest extends MasterNodeReadRequest<ClusterSearchShardsRequest> implements IndicesRequest.Replaceable {
|
|
public class ClusterSearchShardsRequest extends MasterNodeReadRequest<ClusterSearchShardsRequest> implements IndicesRequest.Replaceable {
|
|
- private String[] indices;
|
|
|
|
|
|
+ public static final Version V_5_1_0_UNRELEASED = Version.fromId(5010099);
|
|
|
|
+ private String[] indices = Strings.EMPTY_ARRAY;
|
|
@Nullable
|
|
@Nullable
|
|
private String routing;
|
|
private String routing;
|
|
@Nullable
|
|
@Nullable
|
|
private String preference;
|
|
private String preference;
|
|
- private String[] types = Strings.EMPTY_ARRAY;
|
|
|
|
private IndicesOptions indicesOptions = IndicesOptions.lenientExpandOpen();
|
|
private IndicesOptions indicesOptions = IndicesOptions.lenientExpandOpen();
|
|
|
|
|
|
|
|
|
|
@@ -57,14 +59,9 @@ public class ClusterSearchShardsRequest extends MasterNodeReadRequest<ClusterSea
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public ClusterSearchShardsRequest indices(String... indices) {
|
|
public ClusterSearchShardsRequest indices(String... indices) {
|
|
- if (indices == null) {
|
|
|
|
- throw new IllegalArgumentException("indices must not be null");
|
|
|
|
- } else {
|
|
|
|
- for (int i = 0; i < indices.length; i++) {
|
|
|
|
- if (indices[i] == null) {
|
|
|
|
- throw new IllegalArgumentException("indices[" + i + "] must not be null");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ Objects.requireNonNull(indices, "indices must not be null");
|
|
|
|
+ for (int i = 0; i < indices.length; i++) {
|
|
|
|
+ Objects.requireNonNull(indices[i], "indices[" + i + "] must not be null");
|
|
}
|
|
}
|
|
this.indices = indices;
|
|
this.indices = indices;
|
|
return this;
|
|
return this;
|
|
@@ -88,23 +85,6 @@ public class ClusterSearchShardsRequest extends MasterNodeReadRequest<ClusterSea
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * The document types to execute the search against. Defaults to be executed against
|
|
|
|
- * all types.
|
|
|
|
- */
|
|
|
|
- public String[] types() {
|
|
|
|
- return types;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * The document types to execute the search against. Defaults to be executed against
|
|
|
|
- * all types.
|
|
|
|
- */
|
|
|
|
- public ClusterSearchShardsRequest types(String... types) {
|
|
|
|
- this.types = types;
|
|
|
|
- return this;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* A comma separated list of routing values to control the shards the search will be executed on.
|
|
* A comma separated list of routing values to control the shards the search will be executed on.
|
|
*/
|
|
*/
|
|
@@ -154,7 +134,10 @@ public class ClusterSearchShardsRequest extends MasterNodeReadRequest<ClusterSea
|
|
routing = in.readOptionalString();
|
|
routing = in.readOptionalString();
|
|
preference = in.readOptionalString();
|
|
preference = in.readOptionalString();
|
|
|
|
|
|
- types = in.readStringArray();
|
|
|
|
|
|
+ if (in.getVersion().onOrBefore(V_5_1_0_UNRELEASED)) {
|
|
|
|
+ //types
|
|
|
|
+ in.readStringArray();
|
|
|
|
+ }
|
|
indicesOptions = IndicesOptions.readIndicesOptions(in);
|
|
indicesOptions = IndicesOptions.readIndicesOptions(in);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -170,7 +153,10 @@ public class ClusterSearchShardsRequest extends MasterNodeReadRequest<ClusterSea
|
|
out.writeOptionalString(routing);
|
|
out.writeOptionalString(routing);
|
|
out.writeOptionalString(preference);
|
|
out.writeOptionalString(preference);
|
|
|
|
|
|
- out.writeStringArray(types);
|
|
|
|
|
|
+ if (out.getVersion().onOrBefore(V_5_1_0_UNRELEASED)) {
|
|
|
|
+ //types
|
|
|
|
+ out.writeStringArray(Strings.EMPTY_ARRAY);
|
|
|
|
+ }
|
|
indicesOptions.writeIndicesOptions(out);
|
|
indicesOptions.writeIndicesOptions(out);
|
|
}
|
|
}
|
|
|
|
|