Apache Lucene open-source search software
Exposed the MoreLikeThis "minDocFreq" property for use in MoreLikeThisQuery.java and in XML queries
Mark Harwood1f1528e3cada
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.javaindex 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 Queryint minTermFrequency=1;int maxQueryTerms=5;Set stopWords=null;+ int minDocFreq=-1;/**@@ -50,6 +51,10 @@ public class MoreLikeThisQuery extends Querymlt.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.javaindex 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.xmlindex 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 @@<?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 ofpositions they had initially occupied when they launched a new offensive near the southern port ofBasra early yesterday. A High Command communique said Iraqi troops had won a significant victory