All Products
Search
Document Center

OpenSearch:ProximaScore

Last Updated:Feb 08, 2023

The ProximaScore class is used to calculate the similarity score of a vector index in the query.

Constructor

Function

Description

ProximaScore create(OpsScorerInitParams params, CString indexName)

Creates a ProximaScore object.

Functions

Function

Description

double evaluate(OpsScoreParams params)

Calculates the similarity score of the specified vector index.

Function details

ProximaScore create(OpsScorerInitParams params, CString indexName)

Creates a ProximaScore object. This function is a factory function.

Parameters: params: the parameters that are used for initialization. For more information, see OpsScoreParams.

indexName: the name of an index. You must set a name that is specified in the query.

double evaluate(OpsScoreParams params)

Calculates the similarity score of the specified vector index.

Parameter:

params: the parameters that are used for score calculation. For more information, see OpsScoreParams.

Return value:

The similarity score of the specified vector index.

Sample code:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsRequest;
import com.aliyun.opensearch.cava.framework.OpsDoc;
import com.aliyun.opensearch.cava.features.similarity.ProximaScore;

class BasicSimilarityScorer {
    ProximaScore _f1;
    boolean init(OpsScorerInitParams params) {
        _f1 = ProximaScore.create(params, "vector_index");
        return true;
    }

    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        float s1 = _f1.evaluate(params);
        return s1;
    }
};