diff --git a/docs/reference/indices/optimize.asciidoc b/docs/reference/indices/optimize.asciidoc index 39f94b3e51b..2d2814bf6df 100644 --- a/docs/reference/indices/optimize.asciidoc +++ b/docs/reference/indices/optimize.asciidoc @@ -30,9 +30,6 @@ just marked as deleted. During a merge process of segments, a new segment is created that does not have those deletes. This flag allow to only merge segments that have deletes. Defaults to `false`. -|refresh |Should a refresh be performed after the optimize. Defaults to -`true`. - |flush |Should a flush be performed after the optimize. Defaults to `true`. diff --git a/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeRequest.java index 7f5470eac31..4786b7b18f7 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeRequest.java @@ -19,6 +19,7 @@ package org.elasticsearch.action.admin.indices.optimize; +import org.elasticsearch.Version; import org.elasticsearch.action.support.broadcast.BroadcastOperationRequest; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -46,19 +47,13 @@ public class OptimizeRequest extends BroadcastOperationRequest public static final int MAX_NUM_SEGMENTS = -1; public static final boolean ONLY_EXPUNGE_DELETES = false; public static final boolean FLUSH = true; - public static final boolean REFRESH = true; } private boolean waitForMerge = Defaults.WAIT_FOR_MERGE; - private int maxNumSegments = Defaults.MAX_NUM_SEGMENTS; - private boolean onlyExpungeDeletes = Defaults.ONLY_EXPUNGE_DELETES; - private boolean flush = Defaults.FLUSH; - private boolean refresh = Defaults.FLUSH; - /** * Constructs an optimization request over one or more indices. * @@ -136,28 +131,15 @@ public class OptimizeRequest extends BroadcastOperationRequest return this; } - /** - * Should refresh be performed after the optimization. Defaults to true. - */ - public boolean refresh() { - return refresh; - } - - /** - * Should refresh be performed after the optimization. Defaults to true. - */ - public OptimizeRequest refresh(boolean refresh) { - this.refresh = refresh; - return this; - } - public void readFrom(StreamInput in) throws IOException { super.readFrom(in); waitForMerge = in.readBoolean(); maxNumSegments = in.readInt(); onlyExpungeDeletes = in.readBoolean(); flush = in.readBoolean(); - refresh = in.readBoolean(); + if (in.getVersion().onOrBefore(Version.V_0_90_3)) { + in.readBoolean(); // old refresh flag + } } public void writeTo(StreamOutput out) throws IOException { @@ -166,6 +148,8 @@ public class OptimizeRequest extends BroadcastOperationRequest out.writeInt(maxNumSegments); out.writeBoolean(onlyExpungeDeletes); out.writeBoolean(flush); - out.writeBoolean(refresh); + if (out.getVersion().onOrBefore(Version.V_0_90_3)) { + out.writeBoolean(false); // old refresh flag + } } } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeRequestBuilder.java b/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeRequestBuilder.java index e7e6bac4ed5..d12d24a6560 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeRequestBuilder.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeRequestBuilder.java @@ -74,14 +74,6 @@ public class OptimizeRequestBuilder extends BroadcastOperationRequestBuildertrue. - */ - public OptimizeRequestBuilder setRefresh(boolean refresh) { - request.refresh(refresh); - return this; - } - @Override protected void doExecute(ActionListener listener) { ((IndicesAdminClient) client).optimize(request, listener); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeRequest.java index 6f4ab36ff99..f61e92a98f6 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeRequest.java @@ -19,6 +19,7 @@ package org.elasticsearch.action.admin.indices.optimize; +import org.elasticsearch.Version; import org.elasticsearch.action.support.broadcast.BroadcastShardOperationRequest; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -34,7 +35,6 @@ class ShardOptimizeRequest extends BroadcastShardOperationRequest { private int maxNumSegments = OptimizeRequest.Defaults.MAX_NUM_SEGMENTS; private boolean onlyExpungeDeletes = OptimizeRequest.Defaults.ONLY_EXPUNGE_DELETES; private boolean flush = OptimizeRequest.Defaults.FLUSH; - private boolean refresh = OptimizeRequest.Defaults.REFRESH; ShardOptimizeRequest() { } @@ -45,7 +45,6 @@ class ShardOptimizeRequest extends BroadcastShardOperationRequest { maxNumSegments = request.maxNumSegments(); onlyExpungeDeletes = request.onlyExpungeDeletes(); flush = request.flush(); - refresh = request.refresh(); } boolean waitForMerge() { @@ -64,10 +63,6 @@ class ShardOptimizeRequest extends BroadcastShardOperationRequest { return flush; } - public boolean refresh() { - return refresh; - } - @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); @@ -75,7 +70,9 @@ class ShardOptimizeRequest extends BroadcastShardOperationRequest { maxNumSegments = in.readInt(); onlyExpungeDeletes = in.readBoolean(); flush = in.readBoolean(); - refresh = in.readBoolean(); + if (in.getVersion().onOrBefore(Version.V_0_90_3)) { + in.readBoolean(); // old refresh flag + } } @Override @@ -85,6 +82,8 @@ class ShardOptimizeRequest extends BroadcastShardOperationRequest { out.writeInt(maxNumSegments); out.writeBoolean(onlyExpungeDeletes); out.writeBoolean(flush); - out.writeBoolean(refresh); + if (out.getVersion().onOrBefore(Version.V_0_90_3)) { + out.writeBoolean(false); // old refresh flag + } } } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/optimize/TransportOptimizeAction.java b/src/main/java/org/elasticsearch/action/admin/indices/optimize/TransportOptimizeAction.java index 651d486d9b8..8e836577218 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/optimize/TransportOptimizeAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/optimize/TransportOptimizeAction.java @@ -117,7 +117,6 @@ public class TransportOptimizeAction extends TransportBroadcastOperationAction