Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] [BUG] CompletionSuggestSearchIT.testSkipDuplicates is flaky #11200

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ private void searchLeaf(LeafReaderContext ctx, Weight weight, Collector collecto
}
}
}

// Note: this is called if collection ran successfully, including the above special cases of
// CollectionTerminatedException and TimeExceededException, but no other exception.
leafCollector.finish();
}

private Weight wrapWeight(Weight weight) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.apache.lucene.search.BulkScorer;
import org.apache.lucene.search.CollectionTerminatedException;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.LeafCollector;
import org.apache.lucene.search.Weight;
import org.apache.lucene.search.suggest.document.CompletionQuery;
import org.apache.lucene.search.suggest.document.TopSuggestDocs;
Expand Down Expand Up @@ -108,15 +109,21 @@
for (LeafReaderContext context : searcher.getIndexReader().leaves()) {
BulkScorer scorer = weight.bulkScorer(context);
if (scorer != null) {
LeafCollector leafCollector = null;

Check warning on line 112 in server/src/main/java/org/opensearch/search/suggest/completion/CompletionSuggester.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/search/suggest/completion/CompletionSuggester.java#L112

Added line #L112 was not covered by tests
try {
scorer.score(collector.getLeafCollector(context), context.reader().getLiveDocs());
leafCollector = collector.getLeafCollector(context);
scorer.score(leafCollector, context.reader().getLiveDocs());

Check warning on line 115 in server/src/main/java/org/opensearch/search/suggest/completion/CompletionSuggester.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/search/suggest/completion/CompletionSuggester.java#L114-L115

Added lines #L114 - L115 were not covered by tests
} catch (CollectionTerminatedException e) {
// collection was terminated prematurely
// continue with the following leaf
}
// Note: this is called if collection ran successfully, including the above special cases of
// CollectionTerminatedException and TimeExceededException, but no other exception.
if (leafCollector != null) {
leafCollector.finish();

Check warning on line 123 in server/src/main/java/org/opensearch/search/suggest/completion/CompletionSuggester.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/search/suggest/completion/CompletionSuggester.java#L123

Added line #L123 was not covered by tests
}
}
}
collector.finish();
}

@Override
Expand Down
Loading