LUCENE-1298: Allow MLT to use custom similarity

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@663054 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Grant Ingersoll 2008-06-04 10:41:41 +00:00
parent 455afb322d
commit f89cda6dde
2 changed files with 19 additions and 3 deletions

View File

@ -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

View File

@ -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}.
*