i'm trying to introduce an additional weighting using payloads.
Therefore i implemented my own Similarity class (see below) and implemented
scorePayload().
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
searching.
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 = searcher.search(q, 15);
---------
public class MySimilarity extends DefaultSimilarity {
@Override
public float tf(float freq) {
System.out.println("TF");
return super.tf(freq);
}
@Override
public float scorePayload(int docID, String fieldName, int start,
int end, byte[] payload, int offset,
int length) {
System.out.println("Called!");
if (payload != null) {
float boost = PayloadContainer.getBoost(payload);
System.out.println("Boosting: " + boost);
return boost;
} else {
return 1.0f;
}
}
}
---------
regards
Christoph Hermann
--
Christoph Hermann
Institut für Informatik
Tel: +49 761-203-8171 Fax: +49 761-203-8162
e-mail: hermann@informatik.uni-freiburg.de
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org