Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-10849: MoreLikeThisComponent should expose setMaxDocFreqPct (maxDoc frequency percentage).

Dawid Weissb2ea95c9ecbf
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 9ba932fdab9..e9a22db2953 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -284,6 +284,9 @@ Upgrade Notes
New Features
----------------------
+* SOLR-10849: MoreLikeThisComponent should expose setMaxDocFreqPct (maxDoc
+ frequency percentage). (Dawid Weiss)
+
* SOLR-10307: Allow Passing SSL passwords through environment variables. (Mano Kovacs via Mark Miller)
* SOLR-10721: Provide a way to know when Core Discovery is finished and when all async cores are done loading
diff --git a/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java b/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
index 50ea711e9d5..0d1213695b1 100644
--- a/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
@@ -335,6 +335,13 @@ public class MoreLikeThisHandler extends RequestHandlerBase
mlt.setMaxQueryTerms( params.getInt(MoreLikeThisParams.MAX_QUERY_TERMS, MoreLikeThis.DEFAULT_MAX_QUERY_TERMS));
mlt.setMaxNumTokensParsed(params.getInt(MoreLikeThisParams.MAX_NUM_TOKENS_PARSED, MoreLikeThis.DEFAULT_MAX_NUM_TOKENS_PARSED));
mlt.setBoost( params.getBool(MoreLikeThisParams.BOOST, false ) );
+
+ // There is no default for maxDocFreqPct. Also, it's a bit oddly expressed as an integer value
+ // (percentage of the collection's documents count). We keep Lucene's convention here.
+ if (params.getInt(MoreLikeThisParams.MAX_DOC_FREQ_PCT) != null) {
+ mlt.setMaxDocFreqPct(params.getInt(MoreLikeThisParams.MAX_DOC_FREQ_PCT));
+ }
+
boostFields = SolrPluginUtils.parseFieldBoosts(params.getParams(MoreLikeThisParams.QF));
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/params/MoreLikeThisParams.java b/solr/solrj/src/java/org/apache/solr/common/params/MoreLikeThisParams.java
index c898fdb8dae..919f786ee06 100644
--- a/solr/solrj/src/java/org/apache/solr/common/params/MoreLikeThisParams.java
+++ b/solr/solrj/src/java/org/apache/solr/common/params/MoreLikeThisParams.java
@@ -31,6 +31,7 @@ public interface MoreLikeThisParams
public final static String SIMILARITY_FIELDS = PREFIX + "fl";
public final static String MIN_TERM_FREQ = PREFIX + "mintf";
public final static String MAX_DOC_FREQ = PREFIX + "maxdf";
+ public final static String MAX_DOC_FREQ_PCT = PREFIX + "maxdfpct";
public final static String MIN_DOC_FREQ = PREFIX + "mindf";
public final static String MIN_WORD_LEN = PREFIX + "minwl";
public final static String MAX_WORD_LEN = PREFIX + "maxwl";