Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-2942: ClassCastException when passing non-textual field for clustering

Stanisław Osińskicefa85954d50
diff --git a/solr/contrib/clustering/CHANGES.txt b/solr/contrib/clustering/CHANGES.txt
index 369e6295b14..1baee1dc05d 100644
--- a/solr/contrib/clustering/CHANGES.txt
+++ b/solr/contrib/clustering/CHANGES.txt
@@ -32,6 +32,9 @@ $Id$
* SOLR-2941: NullPointerException on clustering component initialization
when schema does not have a unique key field (Stanislaw Osinski).
+* SOLR-2942: ClassCastException when passing non-textual fields for
+ clustering (Stanislaw Osinski).
+
================== Release 3.5.0 ==================
(No Changes)
diff --git a/solr/contrib/clustering/src/java/org/apache/solr/handler/clustering/carrot2/CarrotClusteringEngine.java b/solr/contrib/clustering/src/java/org/apache/solr/handler/clustering/carrot2/CarrotClusteringEngine.java
index 596d0f75337..57d2012dcf3 100644
--- a/solr/contrib/clustering/src/java/org/apache/solr/handler/clustering/carrot2/CarrotClusteringEngine.java
+++ b/solr/contrib/clustering/src/java/org/apache/solr/handler/clustering/carrot2/CarrotClusteringEngine.java
@@ -69,7 +69,6 @@ import org.carrot2.util.resource.ResourceLookup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@@ -430,7 +429,7 @@ public class CarrotClusteringEngine extends SearchClusteringEngine {
// Create a Carrot2 document
Document carrotDocument = new Document(getConcatenated(sdoc, titleFieldSpec),
- snippet, (String)sdoc.getFieldValue(urlField));
+ snippet, ObjectUtils.toString(sdoc.getFieldValue(urlField), ""));
// Store Solr id of the document, we need it to map document instances
// found in clusters back to identifiers.
@@ -510,7 +509,7 @@ public class CarrotClusteringEngine extends SearchClusteringEngine {
// Join multiple values with a period so that Carrot2 does not pick up
// phrases that cross field value boundaries (in most cases it would
// create useless phrases).
- result.append((String)ite.next()).append(" . ");
+ result.append(ObjectUtils.toString(ite.next())).append(" . ");
}
}
return result.toString().trim();