File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed
modules/percolator/src/main/java/org/elasticsearch/percolator Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 2424import org .elasticsearch .common .io .stream .StreamInput ;
2525import org .elasticsearch .common .io .stream .StreamOutput ;
2626import org .elasticsearch .common .io .stream .Streamable ;
27- import org .elasticsearch .common .xcontent .ToXContent ;
27+ import org .elasticsearch .common .xcontent .ToXContentObject ;
2828import org .elasticsearch .common .xcontent .XContentBuilder ;
2929
3030import java .io .IOException ;
4040 * @deprecated Instead use multi search API with {@link PercolateQueryBuilder}
4141 */
4242@ Deprecated
43- public class MultiPercolateResponse extends ActionResponse implements Iterable <MultiPercolateResponse .Item >, ToXContent {
43+ public class MultiPercolateResponse extends ActionResponse implements Iterable <MultiPercolateResponse .Item >, ToXContentObject {
4444
4545 private Item [] items ;
4646
@@ -73,17 +73,19 @@ public Item[] getItems() {
7373
7474 @ Override
7575 public XContentBuilder toXContent (XContentBuilder builder , Params params ) throws IOException {
76+ builder .startObject ();
7677 builder .startArray (Fields .RESPONSES );
7778 for (MultiPercolateResponse .Item item : items ) {
78- builder .startObject ();
7979 if (item .isFailure ()) {
80+ builder .startObject ();
8081 ElasticsearchException .renderException (builder , params , item .getFailure ());
82+ builder .endObject ();
8183 } else {
8284 item .getResponse ().toXContent (builder , params );
8385 }
84- builder .endObject ();
8586 }
8687 builder .endArray ();
88+ builder .endObject ();
8789 return builder ;
8890 }
8991
Original file line number Diff line number Diff line change 2626import org .elasticsearch .common .io .stream .Streamable ;
2727import org .elasticsearch .common .text .Text ;
2828import org .elasticsearch .common .unit .TimeValue ;
29- import org .elasticsearch .common .xcontent .ToXContent ;
29+ import org .elasticsearch .common .xcontent .ToXContentObject ;
3030import org .elasticsearch .common .xcontent .XContentBuilder ;
3131import org .elasticsearch .rest .action .RestActions ;
3232import org .elasticsearch .search .aggregations .InternalAggregations ;
4545 * @deprecated Instead use search API with {@link PercolateQueryBuilder}
4646 */
4747@ Deprecated
48- public class PercolateResponse extends BroadcastResponse implements Iterable <PercolateResponse .Match >, ToXContent {
48+ public class PercolateResponse extends BroadcastResponse implements Iterable <PercolateResponse .Match >, ToXContentObject {
4949
5050 public static final Match [] EMPTY = new Match [0 ];
5151 // PercolateQuery emits this score if no 'query' is defined in the percolate request
@@ -113,6 +113,13 @@ public Iterator<Match> iterator() {
113113
114114 @ Override
115115 public XContentBuilder toXContent (XContentBuilder builder , Params params ) throws IOException {
116+ builder .startObject ();
117+ innerToXContent (builder , params );
118+ builder .endObject ();
119+ return builder ;
120+ }
121+
122+ public XContentBuilder innerToXContent (XContentBuilder builder , Params params ) throws IOException {
116123 builder .field (Fields .TOOK , tookInMillis );
117124 RestActions .buildBroadcastShardsHeader (builder , params , this );
118125
You can’t perform that action at this time.
0 commit comments