The ProximaScore class is used to calculate the proximity of documents to a vector index in a search.
Constructor
Function | Description |
ProximaScore create(OpsScorerInitParams params, CString indexName) | Creates a ProximaScore object. |
Functions
Function | Description |
double evaluate(OpsScoreParams params) | Calculates the proximity of documents to 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 OpsScorerInitParams.
indexName: the name of a vector index. The vector index must be involved in the search.
double evaluate(OpsScoreParams params)
Calculates the proximity of documents to a vector index.
Parameter:
params: the parameters that are used for score calculation. For more information, see OpsScoreParams.
Return value:
Returns the proximity of documents to 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;
}
};