Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-3807: consume all terms from the enum

Simon Willnauer70501dd8457a
diff --git a/modules/suggest/src/java/org/apache/lucene/search/spell/HighFrequencyDictionary.java b/modules/suggest/src/java/org/apache/lucene/search/spell/HighFrequencyDictionary.java
index bec1c3159b2..6ac023089f5 100644
--- a/modules/suggest/src/java/org/apache/lucene/search/spell/HighFrequencyDictionary.java
+++ b/modules/suggest/src/java/org/apache/lucene/search/spell/HighFrequencyDictionary.java
@@ -91,11 +91,13 @@ public class HighFrequencyDictionary implements Dictionary {
@Override
public BytesRef next() throws IOException {
if (termsEnum != null) {
- BytesRef next = termsEnum.next();
- if (next != null && isFrequent(termsEnum.docFreq())) {
- spare.copyBytes(next);
- return spare;
- }
+ BytesRef next;
+ while ((next = termsEnum.next()) != null) {
+ if (isFrequent(termsEnum.docFreq())) {
+ spare.copyBytes(next);
+ return spare;
+ }
+ }
}
return null;
}