Skip to content

Commit 2ba9fd2

Browse files
olcbeannik9000
authored andcommitted
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
1 parent efb2903 commit 2ba9fd2

File tree

12 files changed

+24
-70
lines changed

12 files changed

+24
-70
lines changed

core/src/main/java/org/elasticsearch/action/delete/DeleteResponse.java

+3-27
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
package org.elasticsearch.action.delete;
2121

2222
import org.elasticsearch.action.DocWriteResponse;
23-
import org.elasticsearch.common.xcontent.XContentBuilder;
2423
import org.elasticsearch.common.xcontent.XContentParser;
2524
import org.elasticsearch.index.shard.ShardId;
2625
import org.elasticsearch.rest.RestStatus;
@@ -37,8 +36,6 @@
3736
*/
3837
public class DeleteResponse extends DocWriteResponse {
3938

40-
private static final String FOUND = "found";
41-
4239
public DeleteResponse() {
4340
}
4441

@@ -64,13 +61,6 @@ public String toString() {
6461
return builder.append("]").toString();
6562
}
6663

67-
@Override
68-
public XContentBuilder innerToXContent(XContentBuilder builder, Params params) throws IOException {
69-
builder.field(FOUND, result == Result.DELETED);
70-
super.innerToXContent(builder, params);
71-
return builder;
72-
}
73-
7464
public static DeleteResponse fromXContent(XContentParser parser) throws IOException {
7565
ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser::getTokenLocation);
7666

@@ -85,16 +75,7 @@ public static DeleteResponse fromXContent(XContentParser parser) throws IOExcept
8575
* Parse the current token and update the parsing context appropriately.
8676
*/
8777
public static void parseXContentFields(XContentParser parser, Builder context) throws IOException {
88-
XContentParser.Token token = parser.currentToken();
89-
String currentFieldName = parser.currentName();
90-
91-
if (FOUND.equals(currentFieldName)) {
92-
if (token.isValue()) {
93-
context.setFound(parser.booleanValue());
94-
}
95-
} else {
96-
DocWriteResponse.parseInnerToXContent(parser, context);
97-
}
78+
DocWriteResponse.parseInnerToXContent(parser, context);
9879
}
9980

10081
/**
@@ -104,15 +85,10 @@ public static void parseXContentFields(XContentParser parser, Builder context) t
10485
*/
10586
public static class Builder extends DocWriteResponse.Builder {
10687

107-
private boolean found = false;
108-
109-
public void setFound(boolean found) {
110-
this.found = found;
111-
}
112-
11388
@Override
11489
public DeleteResponse build() {
115-
DeleteResponse deleteResponse = new DeleteResponse(shardId, type, id, seqNo, primaryTerm, version, found);
90+
DeleteResponse deleteResponse = new DeleteResponse(shardId, type, id, seqNo, primaryTerm, version,
91+
result == Result.DELETED ? true : false);
11692
deleteResponse.setForcedRefresh(forcedRefresh);
11793
if (shardInfo != null) {
11894
deleteResponse.setShardInfo(shardInfo);

core/src/main/java/org/elasticsearch/action/index/IndexResponse.java

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

2222
import org.elasticsearch.action.DocWriteResponse;
2323
import org.elasticsearch.common.Strings;
24-
import org.elasticsearch.common.xcontent.XContentBuilder;
2524
import org.elasticsearch.common.xcontent.XContentParser;
2625
import org.elasticsearch.index.shard.ShardId;
2726
import org.elasticsearch.rest.RestStatus;
@@ -38,8 +37,6 @@
3837
*/
3938
public class IndexResponse extends DocWriteResponse {
4039

41-
private static final String CREATED = "created";
42-
4340
public IndexResponse() {
4441
}
4542

@@ -67,13 +64,6 @@ public String toString() {
6764
return builder.append("]").toString();
6865
}
6966

70-
@Override
71-
public XContentBuilder innerToXContent(XContentBuilder builder, Params params) throws IOException {
72-
super.innerToXContent(builder, params);
73-
builder.field(CREATED, result == Result.CREATED);
74-
return builder;
75-
}
76-
7767
public static IndexResponse fromXContent(XContentParser parser) throws IOException {
7868
ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser::getTokenLocation);
7969

@@ -88,16 +78,7 @@ public static IndexResponse fromXContent(XContentParser parser) throws IOExcepti
8878
* Parse the current token and update the parsing context appropriately.
8979
*/
9080
public static void parseXContentFields(XContentParser parser, Builder context) throws IOException {
91-
XContentParser.Token token = parser.currentToken();
92-
String currentFieldName = parser.currentName();
93-
94-
if (CREATED.equals(currentFieldName)) {
95-
if (token.isValue()) {
96-
context.setCreated(parser.booleanValue());
97-
}
98-
} else {
99-
DocWriteResponse.parseInnerToXContent(parser, context);
100-
}
81+
DocWriteResponse.parseInnerToXContent(parser, context);
10182
}
10283

10384
/**
@@ -107,15 +88,10 @@ public static void parseXContentFields(XContentParser parser, Builder context) t
10788
*/
10889
public static class Builder extends DocWriteResponse.Builder {
10990

110-
private boolean created = false;
111-
112-
public void setCreated(boolean created) {
113-
this.created = created;
114-
}
115-
11691
@Override
11792
public IndexResponse build() {
118-
IndexResponse indexResponse = new IndexResponse(shardId, type, id, seqNo, primaryTerm, version, created);
93+
IndexResponse indexResponse = new IndexResponse(shardId, type, id, seqNo, primaryTerm, version,
94+
result == Result.CREATED ? true : false);
11995
indexResponse.setForcedRefresh(forcedRefresh);
12096
if (shardInfo != null) {
12197
indexResponse.setShardInfo(shardInfo);

core/src/test/java/org/elasticsearch/action/delete/DeleteResponseTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ public void testToXContent() {
4444
{
4545
DeleteResponse response = new DeleteResponse(new ShardId("index", "index_uuid", 0), "type", "id", 3, 17, 5, true);
4646
String output = Strings.toString(response);
47-
assertEquals("{\"found\":true,\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":5,\"result\":\"deleted\"," +
47+
assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":5,\"result\":\"deleted\"," +
4848
"\"_shards\":null,\"_seq_no\":3,\"_primary_term\":17}", output);
4949
}
5050
{
5151
DeleteResponse response = new DeleteResponse(new ShardId("index", "index_uuid", 0), "type", "id", -1, 0, 7, true);
5252
response.setForcedRefresh(true);
5353
response.setShardInfo(new ReplicationResponse.ShardInfo(10, 5));
5454
String output = Strings.toString(response);
55-
assertEquals("{\"found\":true,\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":7,\"result\":\"deleted\"," +
55+
assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":7,\"result\":\"deleted\"," +
5656
"\"forced_refresh\":true,\"_shards\":{\"total\":10,\"successful\":5,\"failed\":0}}", output);
5757
}
5858
}

core/src/test/java/org/elasticsearch/action/index/IndexResponseTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ public void testToXContent() {
4646
IndexResponse indexResponse = new IndexResponse(new ShardId("index", "index_uuid", 0), "type", "id", 3, 17, 5, true);
4747
String output = Strings.toString(indexResponse);
4848
assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":5,\"result\":\"created\",\"_shards\":null," +
49-
"\"_seq_no\":3,\"_primary_term\":17,\"created\":true}", output);
49+
"\"_seq_no\":3,\"_primary_term\":17}", output);
5050
}
5151
{
5252
IndexResponse indexResponse = new IndexResponse(new ShardId("index", "index_uuid", 0), "type", "id", -1, 17, 7, true);
5353
indexResponse.setForcedRefresh(true);
5454
indexResponse.setShardInfo(new ReplicationResponse.ShardInfo(10, 5));
5555
String output = Strings.toString(indexResponse);
5656
assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":7,\"result\":\"created\"," +
57-
"\"forced_refresh\":true,\"_shards\":{\"total\":10,\"successful\":5,\"failed\":0},\"created\":true}", output);
57+
"\"forced_refresh\":true,\"_shards\":{\"total\":10,\"successful\":5,\"failed\":0}}", output);
5858
}
5959
}
6060

docs/reference/docs/bulk.asciidoc

-3
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,13 @@ The result of this bulk operation is:
102102
"successful": 1,
103103
"failed": 0
104104
},
105-
"created": true,
106105
"status": 201,
107106
"_seq_no" : 0,
108107
"_primary_term": 1
109108
}
110109
},
111110
{
112111
"delete": {
113-
"found": false,
114112
"_index": "test",
115113
"_type": "type1",
116114
"_id": "2",
@@ -138,7 +136,6 @@ The result of this bulk operation is:
138136
"successful": 1,
139137
"failed": 0
140138
},
141-
"created": true,
142139
"status": 201,
143140
"_seq_no" : 2,
144141
"_primary_term" : 3

docs/reference/docs/delete.asciidoc

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ The result of the above delete operation is:
2323
"failed" : 0,
2424
"successful" : 2
2525
},
26-
"found" : true,
2726
"_index" : "twitter",
2827
"_type" : "tweet",
2928
"_id" : "1",

docs/reference/docs/index_.asciidoc

-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ The result of the above index operation is:
3232
"_type" : "tweet",
3333
"_id" : "1",
3434
"_version" : 1,
35-
"created" : true,
3635
"_seq_no" : 0,
3736
"_primary_term" : 1,
3837
"result" : created
@@ -232,7 +231,6 @@ The result of the above index operation is:
232231
"_type" : "tweet",
233232
"_id" : "6a8ca01c-7896-48e9-81cc-9f70661fcb32",
234233
"_version" : 1,
235-
"created" : true,
236234
"_seq_no" : 0,
237235
"_primary_term" : 1,
238236
"result": "created"

docs/reference/getting-started.asciidoc

-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ And the response:
386386
"successful" : 1,
387387
"failed" : 0
388388
},
389-
"created" : true,
390389
"_seq_no" : 0,
391390
"_primary_term" : 1
392391
}

docs/reference/ingest/ingest-node.asciidoc

-2
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,6 @@ PUT /myindex/type/1?pipeline=monthlyindex
900900
"successful" : 1,
901901
"failed" : 0
902902
},
903-
"created" : true,
904903
"_seq_no" : 0,
905904
"_primary_term" : 1
906905
}
@@ -1831,7 +1830,6 @@ The response from the above index request:
18311830
},
18321831
"_seq_no": 0,
18331832
"_primary_term": 1,
1834-
"created": true
18351833
}
18361834
--------------------------------------------------
18371835
// TESTRESPONSE

docs/reference/migration/migrate_6_0/docs.asciidoc

+12
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,15 @@ Document modification operations may no longer specify the `version_type` of
99
==== <<upserts,Upserts>> no longer support versions
1010

1111
Adding a `version` to an upsert request is no longer supported.
12+
13+
==== `created` field removed in the Index API
14+
15+
The `created` field has been removed in the Index API as in the `index` and
16+
`create` bulk operations. `operation` field should be used instead.
17+
18+
19+
==== `found` field removed in the Delete API
20+
21+
The `found` field has been removed in the Delete API as in the `delete` bulk
22+
operations. `operation` field should be used instead.
23+

docs/reference/query-dsl/percolate-query.asciidoc

-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ Index response:
172172
"successful": 1,
173173
"failed": 0
174174
},
175-
"created": true,
176175
"result": "created",
177176
"_seq_no" : 0,
178177
"_primary_term" : 1

rest-api-spec/src/main/resources/rest-api-spec/test/bulk/10_basic.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
- match: { items.0.index.status: 400 }
5151
- match: { items.0.index.error.type: illegal_argument_exception }
5252
- match: { items.0.index.error.reason: if _id is specified it must not be empty }
53-
- match: { items.1.index.created: true }
54-
- match: { items.2.index.created: true }
53+
- match: { items.1.index.result: created }
54+
- match: { items.2.index.result: created }
5555

5656
- do:
5757
count:

0 commit comments

Comments
 (0)