lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Hermann <>
Subject scorePayload does not get called
Date Sat, 16 Oct 2010 14:54:38 GMT

i'm trying to introduce an additional weighting using payloads.

Therefore i implemented my own Similarity class (see below) and implemented 

My problem is, that scorePayload() is not called during search.
On the other Hand i overwrote the tf() method and that one gets called during 
I am also using PayloadTermQuery, so that should make the scorePayload() 
method get called.

Anyone has an Idea what i'm doing wrong?

IndexSearcher searcher = getIndexSearcher(dir);
searcher.setSimilarity(new MySimilarity());
Term t = new Term(TikaConstants.FIELD_CONTENT, SEARCHTERM);
Query q = new PayloadTermQuery(t, new AveragePayloadFunction());
TopDocs docs =, 15);
public class MySimilarity extends DefaultSimilarity {
	public float tf(float freq) {
	public float scorePayload(int docID, String fieldName, int start, 
						int end, byte[] payload, int offset, 
						int length) {
		if (payload != null) {
			float boost = PayloadContainer.getBoost(payload); 
			System.out.println("Boosting: "  + boost);
			return boost;
		} else {
			return 1.0f;

Christoph Hermann

Christoph Hermann
Institut für Informatik
Tel: +49 761-203-8171 Fax: +49 761-203-8162

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message