diff --git a/CHANGES.txt b/CHANGES.txt index 72e43d2055b..28b93ad8b48 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -177,6 +177,8 @@ New features 15. LUCENE-1295: Added new method to MoreLikeThis for retrieving interesting terms and made retrieveTerms(int) public. (Grant Ingersoll) +16. LUCENE-1298: MoreLikeThis can now accept a custom Similarity (Grant Ingersoll) + Optimizations 1. LUCENE-705: When building a compound file, use diff --git a/contrib/queries/src/java/org/apache/lucene/search/similar/MoreLikeThis.java b/contrib/queries/src/java/org/apache/lucene/search/similar/MoreLikeThis.java index af715818ae4..e97f0696704 100644 --- a/contrib/queries/src/java/org/apache/lucene/search/similar/MoreLikeThis.java +++ b/contrib/queries/src/java/org/apache/lucene/search/similar/MoreLikeThis.java @@ -276,7 +276,7 @@ public final class MoreLikeThis { /** * For idf() calculations. */ - private Similarity similarity = new DefaultSimilarity(); + private Similarity similarity;// = new DefaultSimilarity(); /** * IndexReader to use @@ -287,10 +287,24 @@ public final class MoreLikeThis { * Constructor requiring an IndexReader. */ public MoreLikeThis(IndexReader ir) { - this.ir = ir; + this(ir, new DefaultSimilarity()); } - /** + public MoreLikeThis(IndexReader ir, Similarity sim){ + this.ir = ir; + this.similarity = sim; + } + + + public Similarity getSimilarity() { + return similarity; + } + + public void setSimilarity(Similarity similarity) { + this.similarity = similarity; + } + + /** * Returns an analyzer that will be used to parse source doc with. The default analyzer * is the {@link #DEFAULT_ANALYZER}. *