ensure bwc wire compatibility
This commit is contained in:
parent
bd4a03a426
commit
40b4f39f9f
|
@ -105,16 +105,16 @@ public interface DocumentRequest<T> extends IndicesRequest {
|
||||||
* Requested operation type to perform on the document
|
* Requested operation type to perform on the document
|
||||||
*/
|
*/
|
||||||
enum OpType {
|
enum OpType {
|
||||||
/**
|
|
||||||
* Creates the resource. Simply adds it to the index, if there is an existing
|
|
||||||
* document with the id, then it won't be removed.
|
|
||||||
*/
|
|
||||||
CREATE(0),
|
|
||||||
/**
|
/**
|
||||||
* Index the source. If there an existing document with the id, it will
|
* Index the source. If there an existing document with the id, it will
|
||||||
* be replaced.
|
* be replaced.
|
||||||
*/
|
*/
|
||||||
INDEX(1),
|
INDEX(0),
|
||||||
|
/**
|
||||||
|
* Creates the resource. Simply adds it to the index, if there is an existing
|
||||||
|
* document with the id, then it won't be removed.
|
||||||
|
*/
|
||||||
|
CREATE(1),
|
||||||
/** Updates a document */
|
/** Updates a document */
|
||||||
UPDATE(2),
|
UPDATE(2),
|
||||||
/** Deletes a document */
|
/** Deletes a document */
|
||||||
|
@ -138,12 +138,22 @@ public interface DocumentRequest<T> extends IndicesRequest {
|
||||||
|
|
||||||
public static OpType fromId(byte id) {
|
public static OpType fromId(byte id) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 0: return CREATE;
|
case 0: return INDEX;
|
||||||
case 1: return INDEX;
|
case 1: return CREATE;
|
||||||
case 2: return UPDATE;
|
case 2: return UPDATE;
|
||||||
case 3: return DELETE;
|
case 3: return DELETE;
|
||||||
default: throw new IllegalArgumentException("Unknown opType: [" + id + "]");
|
default: throw new IllegalArgumentException("Unknown opType: [" + id + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static OpType fromString(String sOpType) {
|
||||||
|
String lowerCase = sOpType.toLowerCase(Locale.ENGLISH);
|
||||||
|
for (OpType opType : OpType.values()) {
|
||||||
|
if (opType.getLowercase().equals(lowerCase)) {
|
||||||
|
return opType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Unknown opType: [" + sOpType + "]");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.action.bulk;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.ExceptionsHelper;
|
import org.elasticsearch.ExceptionsHelper;
|
||||||
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.action.DocWriteResponse;
|
import org.elasticsearch.action.DocWriteResponse;
|
||||||
import org.elasticsearch.action.DocumentRequest.OpType;
|
import org.elasticsearch.action.DocumentRequest.OpType;
|
||||||
import org.elasticsearch.action.delete.DeleteResponse;
|
import org.elasticsearch.action.delete.DeleteResponse;
|
||||||
|
@ -301,7 +302,11 @@ public class BulkItemResponse implements Streamable, StatusToXContent {
|
||||||
@Override
|
@Override
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
public void readFrom(StreamInput in) throws IOException {
|
||||||
id = in.readVInt();
|
id = in.readVInt();
|
||||||
|
if (in.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) {
|
||||||
opType = OpType.fromId(in.readByte());
|
opType = OpType.fromId(in.readByte());
|
||||||
|
} else {
|
||||||
|
opType = OpType.fromString(in.readString());
|
||||||
|
}
|
||||||
|
|
||||||
byte type = in.readByte();
|
byte type = in.readByte();
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
|
|
Loading…
Reference in New Issue