XMoreLikeThis: fix potentially unpositioned enum
This commit is contained in:
parent
1f04d6c2bb
commit
afe9c52f07
|
@ -39,10 +39,7 @@ import org.apache.lucene.analysis.TokenStream;
|
||||||
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
|
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
|
||||||
import org.apache.lucene.document.Document;
|
import org.apache.lucene.document.Document;
|
||||||
import org.apache.lucene.index.*;
|
import org.apache.lucene.index.*;
|
||||||
import org.apache.lucene.search.BooleanClause;
|
import org.apache.lucene.search.*;
|
||||||
import org.apache.lucene.search.BooleanQuery;
|
|
||||||
import org.apache.lucene.search.Query;
|
|
||||||
import org.apache.lucene.search.TermQuery;
|
|
||||||
import org.apache.lucene.search.similarities.DefaultSimilarity;
|
import org.apache.lucene.search.similarities.DefaultSimilarity;
|
||||||
import org.apache.lucene.search.similarities.TFIDFSimilarity;
|
import org.apache.lucene.search.similarities.TFIDFSimilarity;
|
||||||
import org.apache.lucene.util.BytesRef;
|
import org.apache.lucene.util.BytesRef;
|
||||||
|
@ -855,8 +852,11 @@ public final class XMoreLikeThis {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
PostingsEnum docs = termsEnum.postings(null, null);
|
final PostingsEnum docs = termsEnum.postings(null, null);
|
||||||
final int freq = docs.freq();
|
int freq = 0;
|
||||||
|
while(docs != null && docs.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
|
||||||
|
freq += docs.freq();
|
||||||
|
}
|
||||||
|
|
||||||
// increment frequency
|
// increment frequency
|
||||||
Int cnt = termFreqMap.get(term);
|
Int cnt = termFreqMap.get(term);
|
||||||
|
|
Loading…
Reference in New Issue