diff --git a/contrib/queries/src/java/org/apache/lucene/search/similar/MoreLikeThisQuery.java b/contrib/queries/src/java/org/apache/lucene/search/similar/MoreLikeThisQuery.java index 3a5b964999b..4ae8674d35d 100644 --- a/contrib/queries/src/java/org/apache/lucene/search/similar/MoreLikeThisQuery.java +++ b/contrib/queries/src/java/org/apache/lucene/search/similar/MoreLikeThisQuery.java @@ -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; + } } diff --git a/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/LikeThisQueryBuilder.java b/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/LikeThisQueryBuilder.java index 316c94d02b4..e678912c9c0 100644 --- a/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/LikeThisQueryBuilder.java +++ b/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/LikeThisQueryBuilder.java @@ -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)); diff --git a/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/LikeThisQuery.xml b/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/LikeThisQuery.xml index 0c121676a1c..a50d05324f4 100644 --- a/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/LikeThisQuery.xml +++ b/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/LikeThisQuery.xml @@ -1,5 +1,5 @@ - + 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