Retrieves the score a document received during the rough sort phase, so you can use it as input to your fine sort expression.
OpenSearch ranking runs in two phases. The rough sort phase scores up to 10,000 candidate documents using the rough sort expression. Fine sort then applies its algorithm to that smaller set. FirstPhaseScore bridges the two phases: call evaluate() inside your fine sort scorer to get the score a document received in rough sort.
Constructor
| Signature | Description |
|---|---|
FirstPhaseScore create(OpsScorerInitParams params) | Creates a FirstPhaseScore object. |
create() is a factory function. Pass the OpsScorerInitParams object received by your scorer's init() method.
Methods
| Signature | Description |
|---|---|
double evaluate(OpsScoreParams params) | Returns the score the document received in the rough sort phase. |
Parameters
| Parameter | Type | Description |
|---|---|---|
params | OpsScoreParams | Parameters for score calculation. See OpsScoreParams. |
Return value
double — the document's rough sort score.
Example
The following scorer initializes FirstPhaseScore in init() and returns the rough sort score directly in score().
package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.features.FirstPhaseScore;
class BasicSimilarityScorer {
FirstPhaseScore _f1;
boolean init(OpsScorerInitParams params) {
_f1 = FirstPhaseScore.create(params);
return true;
}
double score(OpsScoreParams params) {
return _f1.evaluate(params);
}
}To configure the rough sort expression used by FirstPhaseScore, go to the OpenSearch console.