Skip to content

Commit afa5408

Browse files
committed
Throw error when create is used with external
op_type create should only be used with version_type external Closes elastic#37855
1 parent 4504206 commit afa5408

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java

+9
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.elasticsearch.action.ActionRequestValidationException;
2323
import org.elasticsearch.action.CompositeIndicesRequest;
24+
import org.elasticsearch.action.DocWriteRequest;
2425
import org.elasticsearch.action.index.IndexRequest;
2526
import org.elasticsearch.action.search.SearchRequest;
2627
import org.elasticsearch.common.io.stream.StreamInput;
@@ -37,6 +38,7 @@
3738
import java.io.IOException;
3839

3940
import static org.elasticsearch.action.ValidateActions.addValidationError;
41+
import static org.elasticsearch.index.VersionType.EXTERNAL;
4042
import static org.elasticsearch.index.VersionType.INTERNAL;
4143

4244
/**
@@ -104,7 +106,14 @@ public ActionRequestValidationException validate() {
104106
if (destination.version() != Versions.MATCH_ANY && destination.version() != Versions.MATCH_DELETED) {
105107
e = addValidationError("unsupported version for internal versioning [" + destination.version() + ']', e);
106108
}
109+
} else {
110+
if (destination.opType() == DocWriteRequest.OpType.CREATE) {
111+
e = addValidationError("create operations only support internal versioning. use index instead",
112+
e);
113+
return e;
114+
}
107115
}
116+
108117
if (getRemoteInfo() != null) {
109118
if (getSearchRequest().source().query() != null) {
110119
e = addValidationError("reindex from remote sources should use RemoteInfo's query instead of source's query", e);

0 commit comments

Comments
 (0)