mirror of https://github.com/apache/lucene.git
SOLR-9154: Fix DirectSolrSpellChecker to work when added through the Config API
This commit is contained in:
parent
fb2800b149
commit
93562da610
|
@ -308,6 +308,8 @@ Bug Fixes
|
||||||
|
|
||||||
* SOLR-9495: AIOBE with confusing message for incomplete sort spec in Streaming Expression (Gus Heck, Joel Bernstein)
|
* 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
|
Other Changes
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.lucene.search.spell.StringDistance;
|
||||||
import org.apache.lucene.search.spell.SuggestWord;
|
import org.apache.lucene.search.spell.SuggestWord;
|
||||||
import org.apache.lucene.search.spell.SuggestWordFrequencyComparator;
|
import org.apache.lucene.search.spell.SuggestWordFrequencyComparator;
|
||||||
import org.apache.lucene.search.spell.SuggestWordQueue;
|
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.common.util.NamedList;
|
||||||
import org.apache.solr.core.SolrCore;
|
import org.apache.solr.core.SolrCore;
|
||||||
import org.apache.solr.search.SolrIndexSearcher;
|
import org.apache.solr.search.SolrIndexSearcher;
|
||||||
|
@ -93,6 +94,9 @@ public class DirectSolrSpellChecker extends SolrSpellChecker {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String init(NamedList config, SolrCore core) {
|
public String init(NamedList config, SolrCore core) {
|
||||||
|
|
||||||
|
SolrParams params = SolrParams.toSolrParams(config);
|
||||||
|
|
||||||
LOG.info("init: " + config);
|
LOG.info("init: " + config);
|
||||||
String name = super.init(config, core);
|
String name = super.init(config, core);
|
||||||
|
|
||||||
|
@ -113,37 +117,37 @@ public class DirectSolrSpellChecker extends SolrSpellChecker {
|
||||||
sd = core.getResourceLoader().newInstance(distClass, StringDistance.class);
|
sd = core.getResourceLoader().newInstance(distClass, StringDistance.class);
|
||||||
|
|
||||||
float minAccuracy = DEFAULT_ACCURACY;
|
float minAccuracy = DEFAULT_ACCURACY;
|
||||||
Float accuracy = (Float) config.get(ACCURACY);
|
Float accuracy = params.getFloat(ACCURACY);
|
||||||
if (accuracy != null)
|
if (accuracy != null)
|
||||||
minAccuracy = accuracy;
|
minAccuracy = accuracy;
|
||||||
|
|
||||||
int maxEdits = DEFAULT_MAXEDITS;
|
int maxEdits = DEFAULT_MAXEDITS;
|
||||||
Integer edits = (Integer) config.get(MAXEDITS);
|
Integer edits = params.getInt(MAXEDITS);
|
||||||
if (edits != null)
|
if (edits != null)
|
||||||
maxEdits = edits;
|
maxEdits = edits;
|
||||||
|
|
||||||
int minPrefix = DEFAULT_MINPREFIX;
|
int minPrefix = DEFAULT_MINPREFIX;
|
||||||
Integer prefix = (Integer) config.get(MINPREFIX);
|
Integer prefix = params.getInt(MINPREFIX);
|
||||||
if (prefix != null)
|
if (prefix != null)
|
||||||
minPrefix = prefix;
|
minPrefix = prefix;
|
||||||
|
|
||||||
int maxInspections = DEFAULT_MAXINSPECTIONS;
|
int maxInspections = DEFAULT_MAXINSPECTIONS;
|
||||||
Integer inspections = (Integer) config.get(MAXINSPECTIONS);
|
Integer inspections = params.getInt(MAXINSPECTIONS);
|
||||||
if (inspections != null)
|
if (inspections != null)
|
||||||
maxInspections = inspections;
|
maxInspections = inspections;
|
||||||
|
|
||||||
float minThreshold = DEFAULT_THRESHOLD_TOKEN_FREQUENCY;
|
float minThreshold = DEFAULT_THRESHOLD_TOKEN_FREQUENCY;
|
||||||
Float threshold = (Float) config.get(THRESHOLD_TOKEN_FREQUENCY);
|
Float threshold = params.getFloat(THRESHOLD_TOKEN_FREQUENCY);
|
||||||
if (threshold != null)
|
if (threshold != null)
|
||||||
minThreshold = threshold;
|
minThreshold = threshold;
|
||||||
|
|
||||||
int minQueryLength = DEFAULT_MINQUERYLENGTH;
|
int minQueryLength = DEFAULT_MINQUERYLENGTH;
|
||||||
Integer queryLength = (Integer) config.get(MINQUERYLENGTH);
|
Integer queryLength = params.getInt(MINQUERYLENGTH);
|
||||||
if (queryLength != null)
|
if (queryLength != null)
|
||||||
minQueryLength = queryLength;
|
minQueryLength = queryLength;
|
||||||
|
|
||||||
float maxQueryFrequency = DEFAULT_MAXQUERYFREQUENCY;
|
float maxQueryFrequency = DEFAULT_MAXQUERYFREQUENCY;
|
||||||
Float queryFreq = (Float) config.get(MAXQUERYFREQUENCY);
|
Float queryFreq = params.getFloat(MAXQUERYFREQUENCY);
|
||||||
if (queryFreq != null)
|
if (queryFreq != null)
|
||||||
maxQueryFrequency = queryFreq;
|
maxQueryFrequency = queryFreq;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue