Methods Summary |
---|
public org.apache.lucene.analysis.Analyzer | getAnalyzer()
return analyzer;
|
public java.lang.String | getLikeText()
return likeText;
|
public int | getMaxQueryTerms()
return maxQueryTerms;
|
public int | getMinTermFrequency()
return minTermFrequency;
|
public java.lang.String[] | getMoreLikeFields()
return moreLikeFields;
|
public float | getPercentTermsToMatch()
return percentTermsToMatch;
|
public org.apache.lucene.search.Query | rewrite(org.apache.lucene.index.IndexReader reader)
MoreLikeThis mlt=new MoreLikeThis(reader);
mlt.setFieldNames(moreLikeFields);
mlt.setAnalyzer(analyzer);
mlt.setMinTermFreq(minTermFrequency);
mlt.setMaxQueryTerms(maxQueryTerms);
BooleanQuery bq= (BooleanQuery) mlt.like(new ByteArrayInputStream(likeText.getBytes()));
BooleanClause[] clauses = bq.getClauses();
//make at least half the terms match
bq.setMinimumNumberShouldMatch((int)(clauses.length*percentTermsToMatch));
return bq;
|
public void | setAnalyzer(org.apache.lucene.analysis.Analyzer analyzer)
this.analyzer = analyzer;
|
public void | setLikeText(java.lang.String likeText)
this.likeText = likeText;
|
public void | setMaxQueryTerms(int maxQueryTerms)
this.maxQueryTerms = maxQueryTerms;
|
public void | setMinTermFrequency(int minTermFrequency)
this.minTermFrequency = minTermFrequency;
|
public void | setMoreLikeFields(java.lang.String[] moreLikeFields)
this.moreLikeFields = moreLikeFields;
|
public void | setPercentTermsToMatch(float percentTermsToMatch)
this.percentTermsToMatch = percentTermsToMatch;
|
public java.lang.String | toString(java.lang.String field)
return "like:"+likeText;
|