-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Remove deprecated created and found from index, delete and bulk #25516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same deal here as on Delete. I think you should pass the |
||
indexResponse.setForcedRefresh(forcedRefresh); | ||
if (shardInfo != null) { | ||
indexResponse.setShardInfo(shardInfo); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,15 +102,13 @@ The result of this bulk operation is: | |
"successful": 1, | ||
"failed": 0 | ||
}, | ||
"created": true, | ||
"status": 201, | ||
"_seq_no" : 0, | ||
"_primary_term": 1 | ||
} | ||
}, | ||
{ | ||
"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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm so glad we assert that these are right now! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is exactly the kind of thing I'd miss when removing these without the assertions. |
||
"status": 201, | ||
"_seq_no" : 2, | ||
"_primary_term" : 3 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should pass the Result here. Maybe also add an assertion in the ctor that the result is either
Result.DELETED
orResult.NOT_FOUND
.