|
32 | 32 | import org.elasticsearch.common.logging.Loggers; |
33 | 33 | import org.elasticsearch.common.unit.TimeValue; |
34 | 34 | import org.elasticsearch.common.xcontent.ToXContent; |
| 35 | +import org.elasticsearch.common.xcontent.ToXContentObject; |
35 | 36 | import org.elasticsearch.common.xcontent.XContentBuilder; |
36 | 37 | import org.elasticsearch.common.xcontent.XContentParser; |
37 | 38 | import org.elasticsearch.index.query.QueryBuilder; |
|
69 | 70 | * |
70 | 71 | * @see org.elasticsearch.action.search.SearchRequest#source(SearchSourceBuilder) |
71 | 72 | */ |
72 | | -public final class SearchSourceBuilder extends ToXContentToBytes implements Writeable { |
| 73 | +public final class SearchSourceBuilder extends ToXContentToBytes implements Writeable, ToXContentObject { |
73 | 74 | private static final DeprecationLogger DEPRECATION_LOGGER = |
74 | 75 | new DeprecationLogger(Loggers.getLogger(SearchSourceBuilder.class)); |
75 | 76 |
|
@@ -1098,12 +1099,6 @@ public void parseXContent(QueryParseContext context) throws IOException { |
1098 | 1099 | @Override |
1099 | 1100 | public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { |
1100 | 1101 | builder.startObject(); |
1101 | | - innerToXContent(builder, params); |
1102 | | - builder.endObject(); |
1103 | | - return builder; |
1104 | | - } |
1105 | | - |
1106 | | - public void innerToXContent(XContentBuilder builder, Params params) throws IOException { |
1107 | 1102 | if (from != -1) { |
1108 | 1103 | builder.field(FROM_FIELD.getPreferredName(), from); |
1109 | 1104 | } |
@@ -1199,7 +1194,7 @@ public void innerToXContent(XContentBuilder builder, Params params) throws IOExc |
1199 | 1194 |
|
1200 | 1195 | if (aggregations != null) { |
1201 | 1196 | builder.field(AGGREGATIONS_FIELD.getPreferredName(), aggregations); |
1202 | | - } |
| 1197 | + } |
1203 | 1198 |
|
1204 | 1199 | if (highlightBuilder != null) { |
1205 | 1200 | builder.field(HIGHLIGHT_FIELD.getPreferredName(), highlightBuilder); |
@@ -1232,6 +1227,8 @@ public void innerToXContent(XContentBuilder builder, Params params) throws IOExc |
1232 | 1227 | if (collapse != null) { |
1233 | 1228 | builder.field(COLLAPSE.getPreferredName(), collapse); |
1234 | 1229 | } |
| 1230 | + builder.endObject(); |
| 1231 | + return builder; |
1235 | 1232 | } |
1236 | 1233 |
|
1237 | 1234 | public static class IndexBoost implements Writeable, ToXContent { |
|
0 commit comments