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

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

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x dc289bdac -> fb39e397d


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/fb39e397
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/fb39e397
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/fb39e397

Branch: refs/heads/branch_6x
Commit: fb39e397dbd17fea68f5d46baf80f5af8f5b59d0
Parents: dc289bd
Author: anshum <an...@apache.org>
Authored: Sun Jan 1 15:31:02 2017 -0800
Committer: anshum <an...@apache.org>
Committed: Mon Jan 2 10:33:52 2017 -0800

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


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fb39e397/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 31f243b..6d23599 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -242,6 +242,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/fb39e397/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;