| Index: lucene/core/src/java/org/apache/lucene/index/TermContext.java |
| =================================================================== |
| --- lucene/core/src/java/org/apache/lucene/index/TermContext.java (revision 1678760) |
| +++ lucene/core/src/java/org/apache/lucene/index/TermContext.java (working copy) |
| @@ -117,16 +117,31 @@ |
| * should be derived from a {@link IndexReaderContext}'s leaf ord. |
| */ |
| public void register(TermState state, final int ord, final int docFreq, final long totalTermFreq) { |
| + register(state, ord); |
| + accumulateStatistics(docFreq, totalTermFreq); |
| + } |
| + |
| + /** |
| + * Expert: Registers and associates a {@link TermState} with an leaf ordinal. The |
| + * leaf ordinal should be derived from a {@link IndexReaderContext}'s leaf ord. |
| + * On the contrary to {@link #register(TermState, int, int, long)} this method |
| + * does NOT update term statistics. |
| + */ |
| + public void register(TermState state, final int ord) { |
| assert state != null : "state must not be null"; |
| assert ord >= 0 && ord < states.length; |
| assert states[ord] == null : "state for ord: " + ord |
| + " already registered"; |
| + states[ord] = state; |
| + } |
| + |
| + /** Expert: Accumulate term statistics. */ |
| + public void accumulateStatistics(final int docFreq, final long totalTermFreq) { |
| this.docFreq += docFreq; |
| if (this.totalTermFreq >= 0 && totalTermFreq >= 0) |
| this.totalTermFreq += totalTermFreq; |
| else |
| this.totalTermFreq = -1; |
| - states[ord] = state; |
| } |
| |
| /** |
| Index: lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/FuzzyLikeThisQuery.java |
| =================================================================== |
| --- lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/FuzzyLikeThisQuery.java (revision 1678760) |
| +++ lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/FuzzyLikeThisQuery.java (working copy) |
| @@ -277,11 +277,11 @@ |
| if (terms != null) { |
| TermsEnum termsEnum = terms.iterator(); |
| if (termsEnum.seekExact(term.bytes())) { |
| - int freq = 1 - context.docFreq(); // we want the total df and ttf to be 1 |
| - context.register(termsEnum.termState(), leafContext.ord, freq, freq); |
| + context.register(termsEnum.termState(), leafContext.ord); |
| } |
| } |
| } |
| + context.accumulateStatistics(1, 1); |
| return new TermQuery(term, context); |
| } |
| } |