21
21
22
22
import org .elasticsearch .action .DocWriteResponse ;
23
23
import org .elasticsearch .common .Strings ;
24
- import org .elasticsearch .common .xcontent .XContentBuilder ;
25
24
import org .elasticsearch .common .xcontent .XContentParser ;
26
25
import org .elasticsearch .index .shard .ShardId ;
27
26
import org .elasticsearch .rest .RestStatus ;
38
37
*/
39
38
public class IndexResponse extends DocWriteResponse {
40
39
41
- private static final String CREATED = "created" ;
42
-
43
40
public IndexResponse () {
44
41
}
45
42
@@ -67,13 +64,6 @@ public String toString() {
67
64
return builder .append ("]" ).toString ();
68
65
}
69
66
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
-
77
67
public static IndexResponse fromXContent (XContentParser parser ) throws IOException {
78
68
ensureExpectedToken (XContentParser .Token .START_OBJECT , parser .nextToken (), parser ::getTokenLocation );
79
69
@@ -88,16 +78,7 @@ public static IndexResponse fromXContent(XContentParser parser) throws IOExcepti
88
78
* Parse the current token and update the parsing context appropriately.
89
79
*/
90
80
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 );
101
82
}
102
83
103
84
/**
@@ -107,15 +88,10 @@ public static void parseXContentFields(XContentParser parser, Builder context) t
107
88
*/
108
89
public static class Builder extends DocWriteResponse .Builder {
109
90
110
- private boolean created = false ;
111
-
112
- public void setCreated (boolean created ) {
113
- this .created = created ;
114
- }
115
-
116
91
@ Override
117
92
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 );
119
95
indexResponse .setForcedRefresh (forcedRefresh );
120
96
if (shardInfo != null ) {
121
97
indexResponse .setShardInfo (shardInfo );
0 commit comments