lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Summer Shire <shiresum...@gmail.com>
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(){

    }

    @Override
    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
to org.apache.lucene.search.similarities.Similarity
	at org.apache.solr.schema.IndexSchema$1.getSimilarity(IndexSchema.java:929)
	at org.apache.solr.schema.IndexSchema.getSimilarity(IndexSchema.java:257)
	at org.apache.solr.update.SolrIndexConfig.toIndexWriterConfig(SolrIndexConfig.java:219)
	at org.apache.solr.update.SolrIndexWriter.<init>(SolrIndexWriter.java:77)
	at org.apache.solr.update.SolrIndexWriter.create(SolrIndexWriter.java:64)
	at org.apache.solr.update.DefaultSolrCoreState.createMainIndexWriter(DefaultSolrCoreState.java:267)
	at org.apache.solr.update.DefaultSolrCoreState.getIndexWriter(DefaultSolrCoreState.java:110)
	at org.apache.solr.core.SolrCore.openNewSearcher(SolrCore.java:1440)



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?

thanks,

Summer


Mime
View raw message