mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-06-13 22:58:54 +02:00
ef4c5eb65e
Please note we have force-pushed a new initial commit in order to remove some publicly-available Twitter user information. Note that this process may be required in the future.
38 lines
1.1 KiB
Java
38 lines
1.1 KiB
Java
package com.twitter.search.earlybird.search.relevance.scoring;
|
|
|
|
import org.apache.lucene.search.Explanation;
|
|
|
|
import com.twitter.search.common.schema.base.ImmutableSchemaInterface;
|
|
import com.twitter.search.earlybird.thrift.ThriftSearchResultsRelevanceStats;
|
|
|
|
/*
|
|
* A sample scorer, doesn't really do anything, returns the same score for every document.
|
|
*/
|
|
public class DefaultScoringFunction extends ScoringFunction {
|
|
private float score;
|
|
|
|
public DefaultScoringFunction(ImmutableSchemaInterface schema) {
|
|
super(schema);
|
|
}
|
|
|
|
@Override
|
|
protected float score(float luceneQueryScore) {
|
|
score = luceneQueryScore;
|
|
return luceneQueryScore;
|
|
}
|
|
|
|
@Override
|
|
protected Explanation doExplain(float luceneScore) {
|
|
// just an example - this scoring function will go away soon
|
|
return Explanation.match(luceneScore, "luceneScore=" + luceneScore);
|
|
}
|
|
|
|
@Override
|
|
public void updateRelevanceStats(ThriftSearchResultsRelevanceStats relevanceStats) {
|
|
relevanceStats.setNumScored(relevanceStats.getNumScored() + 1);
|
|
if (score == ScoringFunction.SKIP_HIT) {
|
|
relevanceStats.setNumSkipped(relevanceStats.getNumSkipped() + 1);
|
|
}
|
|
}
|
|
}
|