Skip to content

Commit 576c449

Browse files
committed
Stop cloning index input when loading NRTSuggester (#14271)
Cloning the index input is not necessary when loading the NRTSUggester. Also, it causes a bug as the clone gets closed right before the suggester instance gets returned, which makes it unusable in the later lookup method which slices the index input while it's already closed. This was not discovered so far due to a testing gap that is fixed by #14270
1 parent 7415d5a commit 576c449

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

lucene/CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ Bug Fixes
130130
* GITHUB#14008: Counts provided by taxonomy facets in addition to another aggregation are now returned together with
131131
their corresponding ordinals. (Paul King)
132132
* GITHUB#14027: Make SegmentInfos#readCommit(Directory, String, int) public (Luca Cavanna)
133+
* GITHUB#14271: Stop closing index input when loading NRTSuggester (Luca Cavanna)
133134

134135
Build
135136
---------------------

lucene/suggest/src/java/org/apache/lucene/search/suggest/document/CompletionsTermsReader.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,8 @@ public final class CompletionsTermsReader implements Accountable {
7272
*/
7373
public synchronized NRTSuggester suggester() throws IOException {
7474
if (suggester == null) {
75-
try (IndexInput dictClone = dictIn.clone()) { // let multiple fields load concurrently
76-
dictClone.seek(offset);
77-
suggester = NRTSuggester.load(dictClone, fstLoadMode);
78-
}
75+
IndexInput indexInput = dictIn.slice("NRTSuggester", offset, dictIn.length() - offset);
76+
suggester = NRTSuggester.load(indexInput, fstLoadMode);
7977
}
8078
return suggester;
8179
}

0 commit comments

Comments
 (0)