From 87ac7de4535bd0f23631c18f93259e5a8cd801ed Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Thu, 17 Nov 2011 08:55:10 +0000 Subject: [PATCH] SOLR-2902: List of collations are wrong parsed in SpellCheckResponse git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1203114 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 4 ++++ .../solrj/response/SpellCheckResponse.java | 2 +- .../solrj/response/TestSpellCheckResponse.java | 17 +++++++++++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 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 that can 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.java index 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 expandedCollation = (NamedList) 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.java index 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 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())); + } } }