You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by kr...@apache.org on 2017/01/03 18:48:47 UTC

[36/50] lucene-solr:jira/solr-8593: SOLR-9154: Fix DirectSolrSpellChecker to work when added through the Config API

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


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/93562da6
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/93562da6
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/93562da6

Branch: refs/heads/jira/solr-8593
Commit: 93562da610bf8756351be7720c69872bc1cea727
Parents: fb2800b
Author: anshum <an...@apache.org>
Authored: Sun Jan 1 15:31:02 2017 -0800
Committer: anshum <an...@apache.org>
Committed: Sun Jan 1 15:32:38 2017 -0800

----------------------------------------------------------------------
 solr/CHANGES.txt                                  |  4 +++-
 .../solr/spelling/DirectSolrSpellChecker.java     | 18 +++++++++++-------
 2 files changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/93562da6/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 02167f3..7133638 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
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/93562da6/solr/core/src/java/org/apache/solr/spelling/DirectSolrSpellChecker.java
----------------------------------------------------------------------
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 bbde74a..15fee72 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;