Skip to content

Apache Lucene open-source search software

SOLR-3567: Spellcheck custom parameters not being passed through due to wrong prefix creation

Shalin Shekhar Mangar9b1cb6646f5e
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index bac5b424e5d..5be0a936115 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -230,6 +230,9 @@ Bug Fixes
* SOLR-12377: Don't spin off overseer when Zk controller is closed (Mikhail Khludnev)
+* SOLR-3567: Spellcheck custom parameters not being passed through due to wrong prefix creation.
+ (Josh Lucas via shalin)
+
Optimizations
----------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/SpellCheckComponent.java b/solr/core/src/java/org/apache/solr/handler/component/SpellCheckComponent.java
index c881aa6ef9f..fd5c5123074 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/SpellCheckComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/SpellCheckComponent.java
@@ -339,10 +339,10 @@ public class SpellCheckComponent extends SearchComponent implements SolrCoreAwar
protected SolrParams getCustomParams(String dictionary, SolrParams params) {
ModifiableSolrParams result = new ModifiableSolrParams();
Iterator<String> iter = params.getParameterNamesIterator();
- String prefix = SpellingParams.SPELLCHECK_PREFIX + "." + dictionary + ".";
- while (iter.hasNext()){
+ String prefix = SpellingParams.SPELLCHECK_PREFIX + dictionary + ".";
+ while (iter.hasNext()) {
String nxt = iter.next();
- if (nxt.startsWith(prefix)){
+ if (nxt.startsWith(prefix)) {
result.add(nxt.substring(prefix.length()), params.getParams(nxt));
}
}
diff --git a/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java
index d3b0828d71c..eebb4e4de15 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java
@@ -160,7 +160,7 @@ public class SpellCheckComponentTest extends SolrTestCaseJ4 {
@Test
public void testPerDictionary() throws Exception {
assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", SpellingParams.SPELLCHECK_BUILD, "true", "q","documemt"
- , SpellingParams.SPELLCHECK_DICT, "perDict", SpellingParams.SPELLCHECK_PREFIX + ".perDict.foo", "bar", SpellingParams.SPELLCHECK_PREFIX + ".perDict.bar", "foo")
+ , SpellingParams.SPELLCHECK_DICT, "perDict", SpellingParams.SPELLCHECK_PREFIX + "perDict.foo", "bar", SpellingParams.SPELLCHECK_PREFIX + "perDict.bar", "foo")
,"/spellcheck/suggestions/bar=={'numFound':1, 'startOffset':0, 'endOffset':1, 'suggestion':['foo']}"
,"/spellcheck/suggestions/foo=={'numFound':1, 'startOffset':2, 'endOffset':3, 'suggestion':['bar']}"
);