Exposed the MoreLikeThis "minDocFreq" property for use in MoreLikeThisQuery.java and in XML queries

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@545333 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Harwood 2007-06-07 22:13:37 +00:00
parent 5655c72ecf
commit 1f1528e3ca
3 changed files with 21 additions and 1 deletions

View File

@ -31,6 +31,7 @@ public class MoreLikeThisQuery extends Query
int minTermFrequency=1;
int maxQueryTerms=5;
Set stopWords=null;
int minDocFreq=-1;
/**
@ -50,6 +51,10 @@ public class MoreLikeThisQuery extends Query
mlt.setFieldNames(moreLikeFields);
mlt.setAnalyzer(analyzer);
mlt.setMinTermFreq(minTermFrequency);
if(minDocFreq>=0)
{
mlt.setMinDocFreq(minDocFreq);
}
mlt.setMaxQueryTerms(maxQueryTerms);
mlt.setStopWords(stopWords);
BooleanQuery bq= (BooleanQuery) mlt.like(new ByteArrayInputStream(likeText.getBytes()));
@ -130,4 +135,14 @@ public class MoreLikeThisQuery extends Query
{
this.stopWords = stopWords;
}
public int getMinDocFreq()
{
return minDocFreq;
}
public void setMinDocFreq(int minDocFreq)
{
this.minDocFreq = minDocFreq;
}
}

View File

@ -100,6 +100,11 @@ public class LikeThisQueryBuilder implements QueryBuilder {
mlt.setMinTermFrequency(DOMUtils.getAttribute(e,"minTermFrequency",defaultMinTermFrequency));
mlt.setPercentTermsToMatch(DOMUtils.getAttribute(e,"percentTermsToMatch",defaultPercentTermsToMatch)/100);
mlt.setStopWords(stopWordsSet);
int minDocFreq=DOMUtils.getAttribute(e,"minDocFreq",-1);
if(minDocFreq>=0)
{
mlt.setMinDocFreq(minDocFreq);
}
mlt.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<LikeThisQuery percentTermsToMatch="5" stopWords="Reuter">
<LikeThisQuery percentTermsToMatch="5" stopWords="Reuter" minDocFreq="2">
IRAQI TROOPS REPORTED PUSHING BACK IRANIANS Iraq said today its troops were pushing Iranian forces out of
positions they had initially occupied when they launched a new offensive near the southern port of
Basra early yesterday. A High Command communique said Iraqi troops had won a significant victory