Apache Solr open-source search software
SOLR-2902: List of collations are wrong parsed in SpellCheckResponse
Simon Willnauer87ac7de4535b
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 0cceda931e6..a6f4e7f99a0 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -434,6 +434,10 @@ Bug Fixes* SOLR-2813: Fix HTTP error codes returned when requests contain strings thatcan not be parsed as numbers for Trie fields. (Jeff Crump and hossman)++* SOLR-2902: List of collations are wrong parsed in SpellCheckResponse causing+ a wrong number of collation results in the response.+ (Bastiaan Verhoef, James Dyer via Simon Willnauer)Other Changes----------------------diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/response/SpellCheckResponse.java b/solr/solrj/src/java/org/apache/solr/client/solrj/response/SpellCheckResponse.javaindex 238e3a74a0c..f5347c3f82c 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/response/SpellCheckResponse.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/response/SpellCheckResponse.java@@ -53,7 +53,7 @@ public class SpellCheckResponse {for (Object o : collationInfo) {if (o instanceof String) {collations.add(new Collation()- .setCollationQueryString((String) sugg.getVal(i)));+ .setCollationQueryString((String) o));} else if (o instanceof NamedList) {@SuppressWarnings("unchecked")NamedList<Object> expandedCollation = (NamedList<Object>) o;diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java b/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.javaindex c42c2d52727..2b0f007594a 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java@@ -150,7 +150,7 @@ public class TestSpellCheckResponse extends SolrJettyTestBase {assertTrue("name:(+faith +hope +love)".equals(response.getCollatedResult()) || "name:(+faith +hope +loaves)".equals(response.getCollatedResult()));List<Collation> collations = response.getCollatedResults();- assertTrue(collations.size()==2);+ assertEquals(2, collations.size());for(Collation collation : collations){assertTrue("name:(+faith +hope +love)".equals(collation.getCollationQueryString()) || "name:(+faith +hope +loaves)".equals(collation.getCollationQueryString()));@@ -174,7 +174,20 @@ public class TestSpellCheckResponse extends SolrJettyTestBase {fail("Original Word Should have been either fauth, home or loane.");}}-+ }++ query.set(SpellingParams.SPELLCHECK_COLLATE_EXTENDED_RESULTS, false);+ response = request.process(server).getSpellCheckResponse();+ {+ collations = response.getCollatedResults();+ assertEquals(2, collations.size());+ String collation1 = collations.get(0).getCollationQueryString();+ String collation2 = collations.get(1).getCollationQueryString();+ assertFalse(collation1 + " equals " + collation2,+ collation1.equals(collation2));+ for(Collation collation : collations) {+ assertTrue("name:(+faith +hope +love)".equals(collation.getCollationQueryString()) || "name:(+faith +hope +loaves)".equals(collation.getCollationQueryString()));+ }}}