Skip to content

Apache Lucene open-source search software

SOLR-9154: Fix DirectSolrSpellChecker to work when added through the Config API

anshum93562da610bf
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 02167f31707..71336380d01 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -299,7 +299,7 @@ Bug Fixes
* SOLR-9699,SOLR-4668: fix exception from core status in parallel with core reload (Mikhail Khludnev)
-* SOLR-9859: replication.properties cannot be updated after being written and neither replication.properties or
+* SOLR-9859: replication.properties cannot be updated after being written and neither replication.properties or
index.properties are durable in the face of a crash. (Pushkar Raste, Chris de Kok, Cao Manh Dat, Mark Miller)
* SOLR-9901: Implement move in HdfsDirectoryFactory. (Mark Miller)
@@ -308,6 +308,8 @@ Bug Fixes
* SOLR-9495: AIOBE with confusing message for incomplete sort spec in Streaming Expression (Gus Heck, Joel Bernstein)
+* SOLR-9154: Fix DirectSolrSpellChecker to work when added through the Config API. (Anshum Gupta)
+
Other Changes
----------------------
diff --git a/solr/core/src/java/org/apache/solr/spelling/DirectSolrSpellChecker.java b/solr/core/src/java/org/apache/solr/spelling/DirectSolrSpellChecker.java
index bbde74ae9f4..15fee72c3b2 100644
--- a/solr/core/src/java/org/apache/solr/spelling/DirectSolrSpellChecker.java
+++ b/solr/core/src/java/org/apache/solr/spelling/DirectSolrSpellChecker.java
@@ -29,6 +29,7 @@ import org.apache.lucene.search.spell.StringDistance;
import org.apache.lucene.search.spell.SuggestWord;
import org.apache.lucene.search.spell.SuggestWordFrequencyComparator;
import org.apache.lucene.search.spell.SuggestWordQueue;
+import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.SolrCore;
import org.apache.solr.search.SolrIndexSearcher;
@@ -93,6 +94,9 @@ public class DirectSolrSpellChecker extends SolrSpellChecker {
@Override
public String init(NamedList config, SolrCore core) {
+
+ SolrParams params = SolrParams.toSolrParams(config);
+
LOG.info("init: " + config);
String name = super.init(config, core);
@@ -113,37 +117,37 @@ public class DirectSolrSpellChecker extends SolrSpellChecker {
sd = core.getResourceLoader().newInstance(distClass, StringDistance.class);
float minAccuracy = DEFAULT_ACCURACY;
- Float accuracy = (Float) config.get(ACCURACY);
+ Float accuracy = params.getFloat(ACCURACY);
if (accuracy != null)
minAccuracy = accuracy;
int maxEdits = DEFAULT_MAXEDITS;
- Integer edits = (Integer) config.get(MAXEDITS);
+ Integer edits = params.getInt(MAXEDITS);
if (edits != null)
maxEdits = edits;
int minPrefix = DEFAULT_MINPREFIX;
- Integer prefix = (Integer) config.get(MINPREFIX);
+ Integer prefix = params.getInt(MINPREFIX);
if (prefix != null)
minPrefix = prefix;
int maxInspections = DEFAULT_MAXINSPECTIONS;
- Integer inspections = (Integer) config.get(MAXINSPECTIONS);
+ Integer inspections = params.getInt(MAXINSPECTIONS);
if (inspections != null)
maxInspections = inspections;
float minThreshold = DEFAULT_THRESHOLD_TOKEN_FREQUENCY;
- Float threshold = (Float) config.get(THRESHOLD_TOKEN_FREQUENCY);
+ Float threshold = params.getFloat(THRESHOLD_TOKEN_FREQUENCY);
if (threshold != null)
minThreshold = threshold;
int minQueryLength = DEFAULT_MINQUERYLENGTH;
- Integer queryLength = (Integer) config.get(MINQUERYLENGTH);
+ Integer queryLength = params.getInt(MINQUERYLENGTH);
if (queryLength != null)
minQueryLength = queryLength;
float maxQueryFrequency = DEFAULT_MAXQUERYFREQUENCY;
- Float queryFreq = (Float) config.get(MAXQUERYFREQUENCY);
+ Float queryFreq = params.getFloat(MAXQUERYFREQUENCY);
if (queryFreq != null)
maxQueryFrequency = queryFreq;