Last active
January 3, 2016 07:59
-
-
Save maephisto/8433263 to your computer and use it in GitHub Desktop.
Simple Custom Similarity for Payloads (Solr/Lucene)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.lucene.analysis.payloads.PayloadHelper; | |
import org.apache.lucene.search.similarities.DefaultSimilarity; | |
import org.apache.lucene.util.BytesRef; | |
public class CustomSolrSimilarity extends DefaultSimilarity { | |
@Override | |
public float scorePayload(int doc, int start, int end, BytesRef payload) { | |
if (payload != null) { | |
return PayloadHelper.decodeFloat(payload.bytes);; | |
} | |
return 1.0f; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment