Skip to content

Commit 6224b72

Browse files
authored
Replace the deprecated construction method of TopScoreDocCollectorManager with the new method in Lucene (#18395)
* Replace the deprecated construction method of TopScoreDocCollectorManager with the new method Signed-off-by: Binlong Gao <gbinlong@amazon.com> * Modify changelog Signed-off-by: Binlong Gao <gbinlong@amazon.com> --------- Signed-off-by: Binlong Gao <gbinlong@amazon.com>
1 parent fe4a98d commit 6224b72

File tree

6 files changed

+10
-18
lines changed

6 files changed

+10
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
7676
- Avoid NPE if on SnapshotInfo if 'shallow' boolean not present ([#18187](https://github.com/opensearch-project/OpenSearch/issues/18187))
7777
- Fix 'system call filter not installed' caused when network.host: 0.0.0.0 ([#18309](https://github.com/opensearch-project/OpenSearch/pull/18309))
7878
- Fix MatrixStatsAggregator reuse when mode parameter changes ([#18242](https://github.com/opensearch-project/OpenSearch/issues/18242))
79+
- Replace the deprecated construction method of TopScoreDocCollectorManager with the new method ([#18395](https://github.com/opensearch-project/OpenSearch/pull/18395))
7980

8081
### Security
8182

modules/parent-join/src/main/java/org/opensearch/join/query/ParentChildInnerHitContextBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public TopDocsAndMaxScore topDocs(SearchHit hit) throws IOException {
175175
maxScoreCollector = new MaxScoreCollector();
176176
}
177177
} else {
178-
topDocsCollector = new TopScoreDocCollectorManager(topN, null, Integer.MAX_VALUE, false).newCollector();
178+
topDocsCollector = new TopScoreDocCollectorManager(topN, null, Integer.MAX_VALUE).newCollector();
179179
maxScoreCollector = new MaxScoreCollector();
180180
}
181181
for (LeafReaderContext ctx : context.searcher().getIndexReader().leaves()) {

server/src/main/java/org/opensearch/index/query/NestedQueryBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ public TopDocsAndMaxScore topDocs(SearchHit hit) throws IOException {
495495
maxScoreCollector = new MaxScoreCollector();
496496
}
497497
} else {
498-
topDocsCollector = new TopScoreDocCollectorManager(topN, null, Integer.MAX_VALUE, false).newCollector();
498+
topDocsCollector = new TopScoreDocCollectorManager(topN, null, Integer.MAX_VALUE).newCollector();
499499
maxScoreCollector = new MaxScoreCollector();
500500
}
501501
intersect(weight, innerHitQueryWeight, MultiCollector.wrap(topDocsCollector, maxScoreCollector), ctx);

server/src/main/java/org/opensearch/search/aggregations/bucket/sampler/BestDocsDeferringCollector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public void collect(int doc, long bucket) throws IOException {
124124
// Designed to be overridden by subclasses that may score docs by criteria
125125
// other than Lucene score
126126
protected TopDocsCollector<? extends ScoreDoc> createTopDocsCollector(int size) throws IOException {
127-
return new TopScoreDocCollectorManager(size, null, Integer.MAX_VALUE, false).newCollector();
127+
return new TopScoreDocCollectorManager(size, null, Integer.MAX_VALUE).newCollector();
128128
}
129129

130130
// Can be overridden by subclasses that have a different priority queue implementation

server/src/main/java/org/opensearch/search/aggregations/metrics/TopHitsAggregator.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,7 @@ public void collect(int docId, long bucket) throws IOException {
158158
// but here we create collectors ourselves and we need prevent OOM because of crazy an offset and size.
159159
topN = Math.min(topN, subSearchContext.searcher().getIndexReader().maxDoc());
160160
if (sort == null) {
161-
collectors = new Collectors(
162-
new TopScoreDocCollectorManager(topN, null, Integer.MAX_VALUE, false).newCollector(),
163-
null
164-
);
161+
collectors = new Collectors(new TopScoreDocCollectorManager(topN, null, Integer.MAX_VALUE).newCollector(), null);
165162
} else {
166163
// TODO: can we pass trackTotalHits=subSearchContext.trackTotalHits(){
167164
// Note that this would require to catch CollectionTerminatedException

server/src/main/java/org/opensearch/search/query/TopDocsCollectorContext.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,9 @@ private static TopDocsCollector<?> createCollector(
348348
int hitCountThreshold
349349
) {
350350
if (sortAndFormats == null) {
351-
return new TopScoreDocCollectorManager(numHits, searchAfter, hitCountThreshold, false).newCollector();
351+
return new TopScoreDocCollectorManager(numHits, searchAfter, hitCountThreshold).newCollector();
352352
} else {
353-
return new TopFieldCollectorManager(sortAndFormats.sort, numHits, (FieldDoc) searchAfter, hitCountThreshold, false)
354-
.newCollector();
353+
return new TopFieldCollectorManager(sortAndFormats.sort, numHits, (FieldDoc) searchAfter, hitCountThreshold).newCollector();
355354
}
356355
}
357356

@@ -364,17 +363,12 @@ private static TopDocsCollector<?> createCollector(
364363
if (sortAndFormats == null) {
365364
// See please https://github.com/apache/lucene/pull/450, should be fixed in 9.x
366365
if (searchAfter != null) {
367-
return new TopScoreDocCollectorManager(
368-
numHits,
369-
new FieldDoc(searchAfter.doc, searchAfter.score),
370-
hitCountThreshold,
371-
true
372-
);
366+
return new TopScoreDocCollectorManager(numHits, new FieldDoc(searchAfter.doc, searchAfter.score), hitCountThreshold);
373367
} else {
374-
return new TopScoreDocCollectorManager(numHits, null, hitCountThreshold, true);
368+
return new TopScoreDocCollectorManager(numHits, null, hitCountThreshold);
375369
}
376370
} else {
377-
return new TopFieldCollectorManager(sortAndFormats.sort, numHits, (FieldDoc) searchAfter, hitCountThreshold, true);
371+
return new TopFieldCollectorManager(sortAndFormats.sort, numHits, (FieldDoc) searchAfter, hitCountThreshold);
378372
}
379373
}
380374

0 commit comments

Comments
 (0)