Remove deprecated created and found from index, delete and bulk (#25516)
The created and found fields in index and delete responses became obsolete after the introduction of the result field in index, update and delete responses (#19566). After deprecating the created and found fields in 5.x (#19633), now they are removed. Fixes #19630
This commit is contained in:
parent
efb29031f1
commit
2ba9fd2aec
|
@ -20,7 +20,6 @@
|
|||
package org.elasticsearch.action.delete;
|
||||
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
@ -37,8 +36,6 @@ import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpect
|
|||
*/
|
||||
public class DeleteResponse extends DocWriteResponse {
|
||||
|
||||
private static final String FOUND = "found";
|
||||
|
||||
public DeleteResponse() {
|
||||
}
|
||||
|
||||
|
@ -64,13 +61,6 @@ public class DeleteResponse extends DocWriteResponse {
|
|||
return builder.append("]").toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public XContentBuilder innerToXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.field(FOUND, result == Result.DELETED);
|
||||
super.innerToXContent(builder, params);
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static DeleteResponse fromXContent(XContentParser parser) throws IOException {
|
||||
ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser::getTokenLocation);
|
||||
|
||||
|
@ -85,16 +75,7 @@ public class DeleteResponse extends DocWriteResponse {
|
|||
* Parse the current token and update the parsing context appropriately.
|
||||
*/
|
||||
public static void parseXContentFields(XContentParser parser, Builder context) throws IOException {
|
||||
XContentParser.Token token = parser.currentToken();
|
||||
String currentFieldName = parser.currentName();
|
||||
|
||||
if (FOUND.equals(currentFieldName)) {
|
||||
if (token.isValue()) {
|
||||
context.setFound(parser.booleanValue());
|
||||
}
|
||||
} else {
|
||||
DocWriteResponse.parseInnerToXContent(parser, context);
|
||||
}
|
||||
DocWriteResponse.parseInnerToXContent(parser, context);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,15 +85,10 @@ public class DeleteResponse extends DocWriteResponse {
|
|||
*/
|
||||
public static class Builder extends DocWriteResponse.Builder {
|
||||
|
||||
private boolean found = false;
|
||||
|
||||
public void setFound(boolean found) {
|
||||
this.found = found;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeleteResponse build() {
|
||||
DeleteResponse deleteResponse = new DeleteResponse(shardId, type, id, seqNo, primaryTerm, version, found);
|
||||
DeleteResponse deleteResponse = new DeleteResponse(shardId, type, id, seqNo, primaryTerm, version,
|
||||
result == Result.DELETED ? true : false);
|
||||
deleteResponse.setForcedRefresh(forcedRefresh);
|
||||
if (shardInfo != null) {
|
||||
deleteResponse.setShardInfo(shardInfo);
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.elasticsearch.action.index;
|
|||
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
@ -38,8 +37,6 @@ import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpect
|
|||
*/
|
||||
public class IndexResponse extends DocWriteResponse {
|
||||
|
||||
private static final String CREATED = "created";
|
||||
|
||||
public IndexResponse() {
|
||||
}
|
||||
|
||||
|
@ -67,13 +64,6 @@ public class IndexResponse extends DocWriteResponse {
|
|||
return builder.append("]").toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public XContentBuilder innerToXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
super.innerToXContent(builder, params);
|
||||
builder.field(CREATED, result == Result.CREATED);
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static IndexResponse fromXContent(XContentParser parser) throws IOException {
|
||||
ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser::getTokenLocation);
|
||||
|
||||
|
@ -88,16 +78,7 @@ public class IndexResponse extends DocWriteResponse {
|
|||
* Parse the current token and update the parsing context appropriately.
|
||||
*/
|
||||
public static void parseXContentFields(XContentParser parser, Builder context) throws IOException {
|
||||
XContentParser.Token token = parser.currentToken();
|
||||
String currentFieldName = parser.currentName();
|
||||
|
||||
if (CREATED.equals(currentFieldName)) {
|
||||
if (token.isValue()) {
|
||||
context.setCreated(parser.booleanValue());
|
||||
}
|
||||
} else {
|
||||
DocWriteResponse.parseInnerToXContent(parser, context);
|
||||
}
|
||||
DocWriteResponse.parseInnerToXContent(parser, context);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,15 +88,10 @@ public class IndexResponse extends DocWriteResponse {
|
|||
*/
|
||||
public static class Builder extends DocWriteResponse.Builder {
|
||||
|
||||
private boolean created = false;
|
||||
|
||||
public void setCreated(boolean created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexResponse build() {
|
||||
IndexResponse indexResponse = new IndexResponse(shardId, type, id, seqNo, primaryTerm, version, created);
|
||||
IndexResponse indexResponse = new IndexResponse(shardId, type, id, seqNo, primaryTerm, version,
|
||||
result == Result.CREATED ? true : false);
|
||||
indexResponse.setForcedRefresh(forcedRefresh);
|
||||
if (shardInfo != null) {
|
||||
indexResponse.setShardInfo(shardInfo);
|
||||
|
|
|
@ -44,7 +44,7 @@ public class DeleteResponseTests extends ESTestCase {
|
|||
{
|
||||
DeleteResponse response = new DeleteResponse(new ShardId("index", "index_uuid", 0), "type", "id", 3, 17, 5, true);
|
||||
String output = Strings.toString(response);
|
||||
assertEquals("{\"found\":true,\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":5,\"result\":\"deleted\"," +
|
||||
assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":5,\"result\":\"deleted\"," +
|
||||
"\"_shards\":null,\"_seq_no\":3,\"_primary_term\":17}", output);
|
||||
}
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ public class DeleteResponseTests extends ESTestCase {
|
|||
response.setForcedRefresh(true);
|
||||
response.setShardInfo(new ReplicationResponse.ShardInfo(10, 5));
|
||||
String output = Strings.toString(response);
|
||||
assertEquals("{\"found\":true,\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":7,\"result\":\"deleted\"," +
|
||||
assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":7,\"result\":\"deleted\"," +
|
||||
"\"forced_refresh\":true,\"_shards\":{\"total\":10,\"successful\":5,\"failed\":0}}", output);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class IndexResponseTests extends ESTestCase {
|
|||
IndexResponse indexResponse = new IndexResponse(new ShardId("index", "index_uuid", 0), "type", "id", 3, 17, 5, true);
|
||||
String output = Strings.toString(indexResponse);
|
||||
assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":5,\"result\":\"created\",\"_shards\":null," +
|
||||
"\"_seq_no\":3,\"_primary_term\":17,\"created\":true}", output);
|
||||
"\"_seq_no\":3,\"_primary_term\":17}", output);
|
||||
}
|
||||
{
|
||||
IndexResponse indexResponse = new IndexResponse(new ShardId("index", "index_uuid", 0), "type", "id", -1, 17, 7, true);
|
||||
|
@ -54,7 +54,7 @@ public class IndexResponseTests extends ESTestCase {
|
|||
indexResponse.setShardInfo(new ReplicationResponse.ShardInfo(10, 5));
|
||||
String output = Strings.toString(indexResponse);
|
||||
assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":7,\"result\":\"created\"," +
|
||||
"\"forced_refresh\":true,\"_shards\":{\"total\":10,\"successful\":5,\"failed\":0},\"created\":true}", output);
|
||||
"\"forced_refresh\":true,\"_shards\":{\"total\":10,\"successful\":5,\"failed\":0}}", output);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,6 @@ The result of this bulk operation is:
|
|||
"successful": 1,
|
||||
"failed": 0
|
||||
},
|
||||
"created": true,
|
||||
"status": 201,
|
||||
"_seq_no" : 0,
|
||||
"_primary_term": 1
|
||||
|
@ -110,7 +109,6 @@ The result of this bulk operation is:
|
|||
},
|
||||
{
|
||||
"delete": {
|
||||
"found": false,
|
||||
"_index": "test",
|
||||
"_type": "type1",
|
||||
"_id": "2",
|
||||
|
@ -138,7 +136,6 @@ The result of this bulk operation is:
|
|||
"successful": 1,
|
||||
"failed": 0
|
||||
},
|
||||
"created": true,
|
||||
"status": 201,
|
||||
"_seq_no" : 2,
|
||||
"_primary_term" : 3
|
||||
|
|
|
@ -23,7 +23,6 @@ The result of the above delete operation is:
|
|||
"failed" : 0,
|
||||
"successful" : 2
|
||||
},
|
||||
"found" : true,
|
||||
"_index" : "twitter",
|
||||
"_type" : "tweet",
|
||||
"_id" : "1",
|
||||
|
|
|
@ -32,7 +32,6 @@ The result of the above index operation is:
|
|||
"_type" : "tweet",
|
||||
"_id" : "1",
|
||||
"_version" : 1,
|
||||
"created" : true,
|
||||
"_seq_no" : 0,
|
||||
"_primary_term" : 1,
|
||||
"result" : created
|
||||
|
@ -232,7 +231,6 @@ The result of the above index operation is:
|
|||
"_type" : "tweet",
|
||||
"_id" : "6a8ca01c-7896-48e9-81cc-9f70661fcb32",
|
||||
"_version" : 1,
|
||||
"created" : true,
|
||||
"_seq_no" : 0,
|
||||
"_primary_term" : 1,
|
||||
"result": "created"
|
||||
|
|
|
@ -386,7 +386,6 @@ And the response:
|
|||
"successful" : 1,
|
||||
"failed" : 0
|
||||
},
|
||||
"created" : true,
|
||||
"_seq_no" : 0,
|
||||
"_primary_term" : 1
|
||||
}
|
||||
|
|
|
@ -900,7 +900,6 @@ PUT /myindex/type/1?pipeline=monthlyindex
|
|||
"successful" : 1,
|
||||
"failed" : 0
|
||||
},
|
||||
"created" : true,
|
||||
"_seq_no" : 0,
|
||||
"_primary_term" : 1
|
||||
}
|
||||
|
@ -1831,7 +1830,6 @@ The response from the above index request:
|
|||
},
|
||||
"_seq_no": 0,
|
||||
"_primary_term": 1,
|
||||
"created": true
|
||||
}
|
||||
--------------------------------------------------
|
||||
// TESTRESPONSE
|
||||
|
|
|
@ -9,3 +9,15 @@ Document modification operations may no longer specify the `version_type` of
|
|||
==== <<upserts,Upserts>> no longer support versions
|
||||
|
||||
Adding a `version` to an upsert request is no longer supported.
|
||||
|
||||
==== `created` field removed in the Index API
|
||||
|
||||
The `created` field has been removed in the Index API as in the `index` and
|
||||
`create` bulk operations. `operation` field should be used instead.
|
||||
|
||||
|
||||
==== `found` field removed in the Delete API
|
||||
|
||||
The `found` field has been removed in the Delete API as in the `delete` bulk
|
||||
operations. `operation` field should be used instead.
|
||||
|
||||
|
|
|
@ -172,7 +172,6 @@ Index response:
|
|||
"successful": 1,
|
||||
"failed": 0
|
||||
},
|
||||
"created": true,
|
||||
"result": "created",
|
||||
"_seq_no" : 0,
|
||||
"_primary_term" : 1
|
||||
|
|
|
@ -50,8 +50,8 @@
|
|||
- match: { items.0.index.status: 400 }
|
||||
- match: { items.0.index.error.type: illegal_argument_exception }
|
||||
- match: { items.0.index.error.reason: if _id is specified it must not be empty }
|
||||
- match: { items.1.index.created: true }
|
||||
- match: { items.2.index.created: true }
|
||||
- match: { items.1.index.result: created }
|
||||
- match: { items.2.index.result: created }
|
||||
|
||||
- do:
|
||||
count:
|
||||
|
|
Loading…
Reference in New Issue