Skip to content

Commit 3486a08

Browse files
Remove unused methods from SearchContext (#107111)
A couple methods can be removed here, they're only used on sub-classes. That also cleans up some unsupport operation exception code that is never hit.
1 parent a5e7525 commit 3486a08

File tree

6 files changed

+0
-103
lines changed

6 files changed

+0
-103
lines changed

server/src/main/java/org/elasticsearch/search/DefaultSearchContext.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,6 @@ public SearchContext aggregations(SearchContextAggregations aggregations) {
481481
return this;
482482
}
483483

484-
@Override
485484
public void addSearchExt(SearchExtBuilder searchExtBuilder) {
486485
// it's ok to use the writeable name here given that we enforce it to be the same as the name of the element that gets
487486
// parsed by the corresponding parser. There is one single name and one single way to retrieve the parsed object from the context.
@@ -508,7 +507,6 @@ public SuggestionSearchContext suggest() {
508507
return suggest;
509508
}
510509

511-
@Override
512510
public void suggest(SuggestionSearchContext suggest) {
513511
this.suggest = suggest;
514512
}
@@ -613,7 +611,6 @@ public TimeValue timeout() {
613611
return timeout;
614612
}
615613

616-
@Override
617614
public void timeout(TimeValue timeout) {
618615
this.timeout = timeout;
619616
}
@@ -688,7 +685,6 @@ public FieldDoc searchAfter() {
688685
return searchAfter;
689686
}
690687

691-
@Override
692688
public SearchContext collapse(CollapseContext collapse) {
693689
this.collapse = collapse;
694690
return this;
@@ -786,7 +782,6 @@ public List<String> groupStats() {
786782
return this.groupStats;
787783
}
788784

789-
@Override
790785
public void groupStats(List<String> groupStats) {
791786
this.groupStats = groupStats;
792787
}

server/src/main/java/org/elasticsearch/search/internal/FilteredSearchContext.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,6 @@ public SuggestionSearchContext suggest() {
139139
return in.suggest();
140140
}
141141

142-
@Override
143-
public void suggest(SuggestionSearchContext suggest) {
144-
in.suggest(suggest);
145-
}
146-
147142
@Override
148143
public RankShardContext rankShardContext() {
149144
return in.rankShardContext();
@@ -204,11 +199,6 @@ public TimeValue timeout() {
204199
return in.timeout();
205200
}
206201

207-
@Override
208-
public void timeout(TimeValue timeout) {
209-
in.timeout(timeout);
210-
}
211-
212202
@Override
213203
public int terminateAfter() {
214204
return in.terminateAfter();
@@ -334,11 +324,6 @@ public List<String> groupStats() {
334324
return in.groupStats();
335325
}
336326

337-
@Override
338-
public void groupStats(List<String> groupStats) {
339-
in.groupStats(groupStats);
340-
}
341-
342327
@Override
343328
public boolean version() {
344329
return in.version();
@@ -409,11 +394,6 @@ public long getRelativeTimeInMillis() {
409394
return in.getRelativeTimeInMillis();
410395
}
411396

412-
@Override
413-
public void addSearchExt(SearchExtBuilder searchExtBuilder) {
414-
in.addSearchExt(searchExtBuilder);
415-
}
416-
417397
@Override
418398
public SearchExtBuilder getSearchExt(String name) {
419399
return in.getSearchExt(name);
@@ -444,11 +424,6 @@ public boolean isCancelled() {
444424
return in.isCancelled();
445425
}
446426

447-
@Override
448-
public SearchContext collapse(CollapseContext collapse) {
449-
return in.collapse(collapse);
450-
}
451-
452427
@Override
453428
public CollapseContext collapse() {
454429
return in.collapse();

server/src/main/java/org/elasticsearch/search/internal/SearchContext.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ public final void close() {
122122

123123
public abstract SearchContext aggregations(SearchContextAggregations aggregations);
124124

125-
public abstract void addSearchExt(SearchExtBuilder searchExtBuilder);
126-
127125
public abstract SearchExtBuilder getSearchExt(String name);
128126

129127
public abstract SearchHighlightContext highlight();
@@ -139,8 +137,6 @@ public InnerHitsContext innerHits() {
139137

140138
public abstract SuggestionSearchContext suggest();
141139

142-
public abstract void suggest(SuggestionSearchContext suggest);
143-
144140
public abstract RankShardContext rankShardContext();
145141

146142
public abstract void rankShardContext(RankShardContext rankShardContext);
@@ -217,8 +213,6 @@ public final void assignRescoreDocIds(RescoreDocIds rescoreDocIds) {
217213

218214
public abstract TimeValue timeout();
219215

220-
public abstract void timeout(TimeValue timeout);
221-
222216
public abstract int terminateAfter();
223217

224218
public abstract void terminateAfter(int terminateAfter);
@@ -255,8 +249,6 @@ public final void assignRescoreDocIds(RescoreDocIds rescoreDocIds) {
255249

256250
public abstract FieldDoc searchAfter();
257251

258-
public abstract SearchContext collapse(CollapseContext collapse);
259-
260252
public abstract CollapseContext collapse();
261253

262254
public abstract SearchContext parsedPostFilter(ParsedQuery postFilter);
@@ -310,8 +302,6 @@ public Query rewrittenQuery() {
310302
@Nullable
311303
public abstract List<String> groupStats();
312304

313-
public abstract void groupStats(List<String> groupStats);
314-
315305
public abstract boolean version();
316306

317307
public abstract void version(boolean version);

server/src/main/java/org/elasticsearch/search/internal/SubSearchContext.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import org.apache.lucene.search.Query;
1111
import org.apache.lucene.search.TotalHits;
12-
import org.elasticsearch.core.TimeValue;
1312
import org.elasticsearch.index.query.ParsedQuery;
1413
import org.elasticsearch.search.aggregations.SearchContextAggregations;
1514
import org.elasticsearch.search.collapse.CollapseContext;
@@ -22,9 +21,6 @@
2221
import org.elasticsearch.search.fetch.subphase.highlight.SearchHighlightContext;
2322
import org.elasticsearch.search.query.QuerySearchResult;
2423
import org.elasticsearch.search.sort.SortAndFormats;
25-
import org.elasticsearch.search.suggest.SuggestionSearchContext;
26-
27-
import java.util.List;
2824

2925
public class SubSearchContext extends FilteredSearchContext {
3026

@@ -104,11 +100,6 @@ public void highlight(SearchHighlightContext highlight) {
104100
this.highlight = highlight;
105101
}
106102

107-
@Override
108-
public void suggest(SuggestionSearchContext suggest) {
109-
throw new UnsupportedOperationException("Not supported");
110-
}
111-
112103
@Override
113104
public boolean hasScriptFields() {
114105
return scriptFields != null && scriptFields.fields().isEmpty() == false;
@@ -160,11 +151,6 @@ public SubSearchContext fetchFieldsContext(FetchFieldsContext fetchFieldsContext
160151
return this;
161152
}
162153

163-
@Override
164-
public void timeout(TimeValue timeout) {
165-
throw new UnsupportedOperationException("Not supported");
166-
}
167-
168154
@Override
169155
public void terminateAfter(int terminateAfter) {
170156
throw new UnsupportedOperationException("Not supported");
@@ -269,11 +255,6 @@ public void explain(boolean explain) {
269255
this.explain = explain;
270256
}
271257

272-
@Override
273-
public void groupStats(List<String> groupStats) {
274-
throw new UnsupportedOperationException("Not supported");
275-
}
276-
277258
@Override
278259
public boolean version() {
279260
return version;

server/src/main/java/org/elasticsearch/search/rank/RankSearchContext.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,6 @@ public SearchContext aggregations(SearchContextAggregations aggregations) {
257257
throw new UnsupportedOperationException();
258258
}
259259

260-
@Override
261-
public void addSearchExt(SearchExtBuilder searchExtBuilder) {
262-
throw new UnsupportedOperationException();
263-
}
264-
265260
@Override
266261
public SearchExtBuilder getSearchExt(String name) {
267262
throw new UnsupportedOperationException();
@@ -287,11 +282,6 @@ public SuggestionSearchContext suggest() {
287282
throw new UnsupportedOperationException();
288283
}
289284

290-
@Override
291-
public void suggest(SuggestionSearchContext suggest) {
292-
throw new UnsupportedOperationException();
293-
}
294-
295285
@Override
296286
public RankShardContext rankShardContext() {
297287
throw new UnsupportedOperationException();
@@ -357,11 +347,6 @@ public BitsetFilterCache bitsetFilterCache() {
357347
throw new UnsupportedOperationException();
358348
}
359349

360-
@Override
361-
public void timeout(TimeValue timeout) {
362-
throw new UnsupportedOperationException();
363-
}
364-
365350
@Override
366351
public void terminateAfter(int terminateAfter) {
367352
throw new UnsupportedOperationException();
@@ -397,11 +382,6 @@ public SearchContext searchAfter(FieldDoc searchAfter) {
397382
throw new UnsupportedOperationException();
398383
}
399384

400-
@Override
401-
public SearchContext collapse(CollapseContext collapse) {
402-
throw new UnsupportedOperationException();
403-
}
404-
405385
@Override
406386
public SearchContext parsedPostFilter(ParsedQuery postFilter) {
407387
throw new UnsupportedOperationException();
@@ -457,11 +437,6 @@ public List<String> groupStats() {
457437
throw new UnsupportedOperationException();
458438
}
459439

460-
@Override
461-
public void groupStats(List<String> groupStats) {
462-
throw new UnsupportedOperationException();
463-
}
464-
465440
@Override
466441
public boolean version() {
467442
throw new UnsupportedOperationException();

test/framework/src/main/java/org/elasticsearch/test/TestSearchContext.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,6 @@ public SearchContext aggregations(SearchContextAggregations searchContextAggrega
171171
return this;
172172
}
173173

174-
@Override
175-
public void addSearchExt(SearchExtBuilder searchExtBuilder) {
176-
searchExtBuilders.put(searchExtBuilder.getWriteableName(), searchExtBuilder);
177-
}
178-
179174
@Override
180175
public SearchExtBuilder getSearchExt(String name) {
181176
return searchExtBuilders.get(name);
@@ -194,9 +189,6 @@ public SuggestionSearchContext suggest() {
194189
return null;
195190
}
196191

197-
@Override
198-
public void suggest(SuggestionSearchContext suggest) {}
199-
200192
@Override
201193
public List<RescoreContext> rescore() {
202194
return Collections.emptyList();
@@ -267,9 +259,6 @@ public TimeValue timeout() {
267259
return TimeValue.ZERO;
268260
}
269261

270-
@Override
271-
public void timeout(TimeValue timeout) {}
272-
273262
@Override
274263
public int terminateAfter() {
275264
return terminateAfter;
@@ -340,11 +329,6 @@ public FieldDoc searchAfter() {
340329
return searchAfter;
341330
}
342331

343-
@Override
344-
public SearchContext collapse(CollapseContext collapse) {
345-
return null;
346-
}
347-
348332
@Override
349333
public CollapseContext collapse() {
350334
return null;
@@ -431,9 +415,6 @@ public List<String> groupStats() {
431415
return null;
432416
}
433417

434-
@Override
435-
public void groupStats(List<String> groupStats) {}
436-
437418
@Override
438419
public boolean version() {
439420
return false;

0 commit comments

Comments
 (0)