Skip to content

Commit

Permalink
MatchingDirectoryReader should not use a threaded searcher (elastic#1…
Browse files Browse the repository at this point in the history
…00527)

MatchingDirectoryReader is a test reader wrapper that filters out documents
matching a particular query. For each leaf, we create an IndexSearcher,
execute the query against it and then use that as a filter for the leaf. This searcher
is created using LuceneTestCase.newSearcher() and as such may be multi-
threaded, which triggers extra index checks. For tests that are expecting certain
methods to be called against internal readers a given number of times, these extra
checks can add additional calls which then lead to a failure of test assumptions.

Because this IndexSearcher is only executed against a single leaf it will only ever use
a single thread, and so we can explicitly disable threading here.

Fixes elastic#100487
Fixes elastic#99916
  • Loading branch information
romseygeek committed Oct 10, 2023
1 parent 12f7321 commit c435702
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,7 @@ public MatchingDirectoryReader(DirectoryReader in, Query query) throws IOExcepti
@Override
public LeafReader wrap(LeafReader leaf) {
try {
final IndexSearcher searcher = newSearcher(leaf, false);
final IndexSearcher searcher = newSearcher(leaf, false, true, false);
searcher.setQueryCache(null);
final Weight weight = searcher.createWeight(query, ScoreMode.COMPLETE_NO_SCORES, 1.0f);
final Scorer scorer = weight.scorer(leaf.getContext());
Expand Down

0 comments on commit c435702

Please sign in to comment.