OpType(byte id) { this.id = id; this.lowercase = this.toString().toLowerCase(Locale.ENGLISH); }
public IndexOptions(JsonObject json) { super(json); id = json.getString(FIELD_ID); timestamp = json.getString(FIELD_TIMESTAMP); ttl = json.getLong(FIELD_TTL); String s = json.getString(FIELD_OP_TYPE); if (s != null) opType = IndexRequest.OpType.fromString(s); }
setResponse(item, new BulkItemResponse(item.id(), indexRequest.opType().lowercase(), indexResponse)); } catch (Throwable e) { setResponse(item, item.getPrimaryResponse()); } else { setResponse(item, new BulkItemResponse(item.id(), indexRequest.opType().lowercase(), new BulkItemResponse.Failure(request.index(), indexRequest.type(), indexRequest.id(), e)));
if (sOpType != null) { try { indexRequest.opType(IndexRequest.OpType.fromString(sOpType)); } catch (IllegalArgumentException eia){ try {
out.writeByte(opType.id()); out.writeBoolean(refresh); out.writeLong(version);
EsRequestLogInfo logInfo = new EsRequestLogInfo(index, type, id, routingId, data, opType.toString(), version); this.fireEvent(Event.afterCreate, logInfo);
if (sOpType != null) { try { putRequest.opType(IndexRequest.OpType.fromString(sOpType)); } catch (IllegalArgumentException eia){ try {
@Override public void onFailure(Throwable e) { // create failures for all relevant requests for (BulkItemRequest request : requests) { if (request.request() instanceof IndexRequest) { IndexRequest indexRequest = (IndexRequest) request.request(); responses.set(request.id(), new BulkItemResponse(request.id(), indexRequest.opType().toString().toLowerCase(Locale.ENGLISH), new BulkItemResponse.Failure(concreteIndices.getConcreteIndex(indexRequest.index()), indexRequest.type(), indexRequest.id(), e))); } else if (request.request() instanceof DeleteRequest) { DeleteRequest deleteRequest = (DeleteRequest) request.request(); responses.set(request.id(), new BulkItemResponse(request.id(), "delete", new BulkItemResponse.Failure(concreteIndices.getConcreteIndex(deleteRequest.index()), deleteRequest.type(), deleteRequest.id(), e))); } else if (request.request() instanceof UpdateRequest) { UpdateRequest updateRequest = (UpdateRequest) request.request(); responses.set(request.id(), new BulkItemResponse(request.id(), "update", new BulkItemResponse.Failure(concreteIndices.getConcreteIndex(updateRequest.index()), updateRequest.type(), updateRequest.id(), e))); } } if (counter.decrementAndGet() == 0) { finishHim(); } }
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); if (in.getVersion().before(Version.V_2_3_0)) { type = in.readString(); } else { type = in.readOptionalString(); } id = in.readOptionalString(); routing = in.readOptionalString(); parent = in.readOptionalString(); timestamp = in.readOptionalString(); if (in.getVersion().before(Version.V_2_2_0)) { long ttl = in.readLong(); if (ttl == -1) { this.ttl = null; } else { ttl(ttl); } } else { ttl = in.readBoolean() ? TimeValue.readTimeValue(in) : null; } source = in.readBytesReference(); opType = OpType.fromId(in.readByte()); refresh = in.readBoolean(); version = in.readLong(); versionType = VersionType.fromValue(in.readByte()); autoGeneratedId = in.readBoolean(); }
/** * Sets a string representation of the {@link #opType(org.elasticsearch.action.index.IndexRequest.OpType)}. Can * be either "index" or "create". */ public IndexRequest opType(String opType) { return opType(OpType.fromString(opType)); }
@Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeString(scriptLang); out.writeOptionalString(id); out.writeBytesReference(source); out.writeByte(opType.id()); out.writeLong(version); out.writeByte(versionType.getValue()); }
/** * Sets a string representation of the {@link #setOpType(org.elasticsearch.action.index.IndexRequest.OpType)}. Can * be either "index" or "create". */ public PutIndexedScriptRequestBuilder setOpType(String opType) { request.opType(IndexRequest.OpType.fromString(opType)); return this; }
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); scriptLang = in.readString(); id = in.readOptionalString(); source = in.readBytesReference(); opType = IndexRequest.OpType.fromId(in.readByte()); version = in.readLong(); versionType = VersionType.fromValue(in.readByte()); }
@Override public JsonObject toJson() { JsonObject json = super.toJson(); if (getId() != null) json.put(FIELD_ID, getId()); if (getOpType() != null) json.put(FIELD_OP_TYPE, getOpType().toString().toLowerCase()); if (getTimestamp() != null) json.put(FIELD_TIMESTAMP, getTimestamp()); if (getTtl() != null) json.put(FIELD_TTL, getTtl()); return json; }
/** * Sets a string representation of the {@link #setOpType(org.elasticsearch.action.index.IndexRequest.OpType)}. Can * be either "index" or "create". */ public IndexRequestBuilder setOpType(String opType) { request.opType(IndexRequest.OpType.fromString(opType)); return this; }