All Products
Search
Document Center

FirstPhaseScore

Last Updated: Sep 09, 2021

Overview

The relevance-based sorts performed by OpenSearch are divided into two phases. The first phase is rough sort and the second phase is fine sort. In the rough sort phase, you can specify a rough sort expression in the OpenSearch console. Then, you can use the FirstPhaseScore object to obtain the document scores that are calculated by using the rough sort expression. To distinguish between the scores that are calculated by using the rough sort expression and those by using the fine sort expression, a maximum of 10,000 documents can be retrieved in the rough sort phase.

Constructor

Function

Description

FirstPhaseScore create(OpsScorerInitParams params)

Creates a FirstPhaseScore object.

Function

Function

Description

double evaluate(OpsScoreParams params)

Obtains the document scores that are calculated by using the rough sort expression.

Function details

FirstPhaseScore create(OpsScorerInitParams params)

A factory function that is used to create a FirstPhaseScore object. Parameter: params: the parameters that are used for initialization. For more information, see OpsScorerInitParams.

double evaluate(OpsScoreParams params)

Obtains the document scores that are calculated by using the rough sort expression. Parameter: params: the parameters that are used for score calculation. For more information, see OpsScoreParams. Return results: the document scores that are calculated in the rough sort phase. Sample code:

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);
    }
}