lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Summer Shire <>
Subject Overriding DefaultSimilarity Cast Exception 4.5.1
Date Tue, 28 Jan 2014 00:41:24 GMT
Hi all,

I am using Solr and Lucene 4.5.1
and I have a Payload Similarity that extends DefaultSimilarity

my schema.xml specifies the default Similarity tag
<similarity class="<mypackage>.PayloadSimilarity"/>

/** my similarity class**/
public class PayloadSimilarity extends DefaultSimilarity {

    public PayloadSimilarity(){


    public float scorePayload(int doc, int start, int end, BytesRef payload) {
        if (payload != null) {
          return PayloadHelper.decodeFloat(payload.bytes, payload.offset);
        } else {
          return 1.0f;


there are no compile errors but I get runtime exception

Caused by: java.lang.ClassCastException: <mypackage>.PayloadSimilarity cannot be cast
	at org.apache.solr.schema.IndexSchema$1.getSimilarity(
	at org.apache.solr.schema.IndexSchema.getSimilarity(
	at org.apache.solr.update.SolrIndexConfig.toIndexWriterConfig(
	at org.apache.solr.update.SolrIndexWriter.<init>(
	at org.apache.solr.update.SolrIndexWriter.create(
	at org.apache.solr.update.DefaultSolrCoreState.createMainIndexWriter(
	at org.apache.solr.update.DefaultSolrCoreState.getIndexWriter(
	at org.apache.solr.core.SolrCore.openNewSearcher(

Why would this be happening. if Solr was not able to find my PayloadSimilarity class then
the error message would have been different.

any inputs?



View raw message