Created
February 8, 2013 11:14
-
-
Save anonymous/4738207 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
Term payload similarity | |
*/ | |
public class TermPayloadSimilarity extends DefaultSimilarity{ | |
@Override | |
public float scorePayload(int docId, String fieldName, int start, int end, byte[] payload, int offset, int length) { | |
if(payload != null){ | |
return PayloadHelper.decodeFloat(payload); | |
} | |
else{ | |
return super.scorePayload(docId, fieldName, start, end, payload, offset, length); | |
} | |
} | |
} | |
/* | |
Provider I sed in index configuration | |
*/ | |
public class TermpayloadSimilarityProvider extends AbstractSimilarityProvider<TermPayloadSimilarity>{ | |
TermPayloadSimilarity similarity; | |
@Inject | |
public TermpayloadSimilarityProvider(Index index, @IndexSettings Settings indexSettings, String name) { | |
super(index, indexSettings, name); | |
similarity = new TermPayloadSimilarity(); | |
} | |
@Override | |
public TermPayloadSimilarity get() { | |
return similarity; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment