diff --git a/core/src/main/java/org/elasticsearch/action/delete/DeleteResponse.java b/core/src/main/java/org/elasticsearch/action/delete/DeleteResponse.java index 1e42537395f7b..a7b9b06473243 100644 --- a/core/src/main/java/org/elasticsearch/action/delete/DeleteResponse.java +++ b/core/src/main/java/org/elasticsearch/action/delete/DeleteResponse.java @@ -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 @@ */ public class DeleteResponse extends DocWriteResponse { - private static final String FOUND = "found"; - public DeleteResponse() { } @@ -64,13 +61,6 @@ public String toString() { 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 static DeleteResponse fromXContent(XContentParser parser) throws IOExcept * 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 static void parseXContentFields(XContentParser parser, Builder context) t */ 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); diff --git a/core/src/main/java/org/elasticsearch/action/index/IndexResponse.java b/core/src/main/java/org/elasticsearch/action/index/IndexResponse.java index f3b71d590ff88..743086165f689 100644 --- a/core/src/main/java/org/elasticsearch/action/index/IndexResponse.java +++ b/core/src/main/java/org/elasticsearch/action/index/IndexResponse.java @@ -21,7 +21,6 @@ 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 @@ */ public class IndexResponse extends DocWriteResponse { - private static final String CREATED = "created"; - public IndexResponse() { } @@ -67,13 +64,6 @@ public String toString() { 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 static IndexResponse fromXContent(XContentParser parser) throws IOExcepti * 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 static void parseXContentFields(XContentParser parser, Builder context) t */ 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); diff --git a/core/src/test/java/org/elasticsearch/action/delete/DeleteResponseTests.java b/core/src/test/java/org/elasticsearch/action/delete/DeleteResponseTests.java index b90ac66b42080..8f4e22e0fd221 100644 --- a/core/src/test/java/org/elasticsearch/action/delete/DeleteResponseTests.java +++ b/core/src/test/java/org/elasticsearch/action/delete/DeleteResponseTests.java @@ -44,7 +44,7 @@ public void testToXContent() { { 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 void testToXContent() { 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); } } diff --git a/core/src/test/java/org/elasticsearch/action/index/IndexResponseTests.java b/core/src/test/java/org/elasticsearch/action/index/IndexResponseTests.java index feeded03f88d4..be67834576e2b 100644 --- a/core/src/test/java/org/elasticsearch/action/index/IndexResponseTests.java +++ b/core/src/test/java/org/elasticsearch/action/index/IndexResponseTests.java @@ -46,7 +46,7 @@ public void testToXContent() { 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 void testToXContent() { 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); } } diff --git a/docs/reference/docs/bulk.asciidoc b/docs/reference/docs/bulk.asciidoc index 513a5ec61bb74..a0d89abb5d7c5 100644 --- a/docs/reference/docs/bulk.asciidoc +++ b/docs/reference/docs/bulk.asciidoc @@ -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 diff --git a/docs/reference/docs/delete.asciidoc b/docs/reference/docs/delete.asciidoc index f26a7fc64d044..b4f97e721b911 100644 --- a/docs/reference/docs/delete.asciidoc +++ b/docs/reference/docs/delete.asciidoc @@ -23,7 +23,6 @@ The result of the above delete operation is: "failed" : 0, "successful" : 2 }, - "found" : true, "_index" : "twitter", "_type" : "tweet", "_id" : "1", diff --git a/docs/reference/docs/index_.asciidoc b/docs/reference/docs/index_.asciidoc index 2f042aec132ba..a2cdc94bde795 100644 --- a/docs/reference/docs/index_.asciidoc +++ b/docs/reference/docs/index_.asciidoc @@ -30,7 +30,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 @@ -230,7 +229,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" diff --git a/docs/reference/getting-started.asciidoc b/docs/reference/getting-started.asciidoc index ee3b30d704e81..1bd6fe3f1bca5 100755 --- a/docs/reference/getting-started.asciidoc +++ b/docs/reference/getting-started.asciidoc @@ -387,7 +387,6 @@ And the response: "successful" : 1, "failed" : 0 }, - "created" : true, "_seq_no" : 0, "_primary_term" : 1 } diff --git a/docs/reference/ingest/ingest-node.asciidoc b/docs/reference/ingest/ingest-node.asciidoc index 7759dd7643330..cf8bdda0e977e 100644 --- a/docs/reference/ingest/ingest-node.asciidoc +++ b/docs/reference/ingest/ingest-node.asciidoc @@ -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 diff --git a/docs/reference/migration/migrate_6_0/docs.asciidoc b/docs/reference/migration/migrate_6_0/docs.asciidoc index 9b4ad82a32d9c..a7e34090e9e41 100644 --- a/docs/reference/migration/migrate_6_0/docs.asciidoc +++ b/docs/reference/migration/migrate_6_0/docs.asciidoc @@ -9,3 +9,15 @@ Document modification operations may no longer specify the `version_type` of ==== <> 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. + diff --git a/docs/reference/query-dsl/percolate-query.asciidoc b/docs/reference/query-dsl/percolate-query.asciidoc index 24511ad60fb73..84b3cd5c44789 100644 --- a/docs/reference/query-dsl/percolate-query.asciidoc +++ b/docs/reference/query-dsl/percolate-query.asciidoc @@ -172,7 +172,6 @@ Index response: "successful": 1, "failed": 0 }, - "created": true, "result": "created", "_seq_no" : 0, "_primary_term" : 1 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/10_basic.yml index 2d9c37f20be88..3eaf8016e1dd0 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/10_basic.yml @@ -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: