40
40
import org .opensearch .search .SearchExtBuilder ;
41
41
import org .opensearch .search .SearchHits ;
42
42
import org .opensearch .search .aggregations .Aggregations ;
43
+ import org .opensearch .search .externalengine .QueryEngineExtBuilder ;
43
44
import org .opensearch .search .profile .ProfileShardResult ;
44
45
import org .opensearch .search .profile .SearchProfileShardResults ;
45
46
import org .opensearch .search .suggest .Suggest ;
@@ -74,6 +75,7 @@ public class SearchResponseSections implements ToXContentFragment {
74
75
protected final Boolean terminatedEarly ;
75
76
protected final int numReducePhases ;
76
77
protected final List <SearchExtBuilder > searchExtBuilders = new ArrayList <>();
78
+ protected final List <QueryEngineExtBuilder > queryEngineExtBuilders = new ArrayList <>();
77
79
78
80
public SearchResponseSections (
79
81
SearchHits hits ,
@@ -84,7 +86,7 @@ public SearchResponseSections(
84
86
SearchProfileShardResults profileResults ,
85
87
int numReducePhases
86
88
) {
87
- this (hits , aggregations , suggest , timedOut , terminatedEarly , profileResults , numReducePhases , Collections .emptyList ());
89
+ this (hits , aggregations , suggest , timedOut , terminatedEarly , profileResults , numReducePhases , Collections .emptyList (), Collections . emptyList () );
88
90
}
89
91
90
92
public SearchResponseSections (
@@ -107,6 +109,28 @@ public SearchResponseSections(
107
109
this .searchExtBuilders .addAll (Objects .requireNonNull (searchExtBuilders , "searchExtBuilders must not be null" ));
108
110
}
109
111
112
+ public SearchResponseSections (
113
+ SearchHits hits ,
114
+ Aggregations aggregations ,
115
+ Suggest suggest ,
116
+ boolean timedOut ,
117
+ Boolean terminatedEarly ,
118
+ SearchProfileShardResults profileResults ,
119
+ int numReducePhases ,
120
+ List <SearchExtBuilder > searchExtBuilders ,
121
+ List <QueryEngineExtBuilder > queryEngineExtBuilders
122
+ ) {
123
+ this .hits = hits ;
124
+ this .aggregations = aggregations ;
125
+ this .suggest = suggest ;
126
+ this .profileResults = profileResults ;
127
+ this .timedOut = timedOut ;
128
+ this .terminatedEarly = terminatedEarly ;
129
+ this .numReducePhases = numReducePhases ;
130
+ this .searchExtBuilders .addAll (Objects .requireNonNull (searchExtBuilders , "searchExtBuilders must not be null" ));
131
+ this .queryEngineExtBuilders .addAll (Objects .requireNonNull (queryEngineExtBuilders , "queryEngineExtBuilders must not be null" ));
132
+ }
133
+
110
134
public final boolean timedOut () {
111
135
return this .timedOut ;
112
136
}
@@ -166,6 +190,13 @@ public final XContentBuilder toXContent(XContentBuilder builder, Params params)
166
190
}
167
191
builder .endObject ();
168
192
}
193
+
194
+ if (!queryEngineExtBuilders .isEmpty ()) {
195
+ for (QueryEngineExtBuilder queryEngineExtBuilder : queryEngineExtBuilders ) {
196
+ queryEngineExtBuilder .toXContent (builder , params );
197
+ }
198
+ }
199
+
169
200
return builder ;
170
201
}
171
202
0 commit comments