mirror of https://github.com/apache/lucene.git
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:
parent
5655c72ecf
commit
1f1528e3ca
|
@ -31,6 +31,7 @@ public class MoreLikeThisQuery extends Query
|
||||||
int minTermFrequency=1;
|
int minTermFrequency=1;
|
||||||
int maxQueryTerms=5;
|
int maxQueryTerms=5;
|
||||||
Set stopWords=null;
|
Set stopWords=null;
|
||||||
|
int minDocFreq=-1;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,6 +51,10 @@ public class MoreLikeThisQuery extends Query
|
||||||
mlt.setFieldNames(moreLikeFields);
|
mlt.setFieldNames(moreLikeFields);
|
||||||
mlt.setAnalyzer(analyzer);
|
mlt.setAnalyzer(analyzer);
|
||||||
mlt.setMinTermFreq(minTermFrequency);
|
mlt.setMinTermFreq(minTermFrequency);
|
||||||
|
if(minDocFreq>=0)
|
||||||
|
{
|
||||||
|
mlt.setMinDocFreq(minDocFreq);
|
||||||
|
}
|
||||||
mlt.setMaxQueryTerms(maxQueryTerms);
|
mlt.setMaxQueryTerms(maxQueryTerms);
|
||||||
mlt.setStopWords(stopWords);
|
mlt.setStopWords(stopWords);
|
||||||
BooleanQuery bq= (BooleanQuery) mlt.like(new ByteArrayInputStream(likeText.getBytes()));
|
BooleanQuery bq= (BooleanQuery) mlt.like(new ByteArrayInputStream(likeText.getBytes()));
|
||||||
|
@ -130,4 +135,14 @@ public class MoreLikeThisQuery extends Query
|
||||||
{
|
{
|
||||||
this.stopWords = stopWords;
|
this.stopWords = stopWords;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMinDocFreq()
|
||||||
|
{
|
||||||
|
return minDocFreq;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinDocFreq(int minDocFreq)
|
||||||
|
{
|
||||||
|
this.minDocFreq = minDocFreq;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,11 @@ public class LikeThisQueryBuilder implements QueryBuilder {
|
||||||
mlt.setMinTermFrequency(DOMUtils.getAttribute(e,"minTermFrequency",defaultMinTermFrequency));
|
mlt.setMinTermFrequency(DOMUtils.getAttribute(e,"minTermFrequency",defaultMinTermFrequency));
|
||||||
mlt.setPercentTermsToMatch(DOMUtils.getAttribute(e,"percentTermsToMatch",defaultPercentTermsToMatch)/100);
|
mlt.setPercentTermsToMatch(DOMUtils.getAttribute(e,"percentTermsToMatch",defaultPercentTermsToMatch)/100);
|
||||||
mlt.setStopWords(stopWordsSet);
|
mlt.setStopWords(stopWordsSet);
|
||||||
|
int minDocFreq=DOMUtils.getAttribute(e,"minDocFreq",-1);
|
||||||
|
if(minDocFreq>=0)
|
||||||
|
{
|
||||||
|
mlt.setMinDocFreq(minDocFreq);
|
||||||
|
}
|
||||||
|
|
||||||
mlt.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
|
mlt.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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
|
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
|
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
|
Basra early yesterday. A High Command communique said Iraqi troops had won a significant victory
|
||||||
|
|
Loading…
Reference in New Issue