Overview
The QueryTermCount class is used to calculate the number of terms after analysis.
Functions
Function | Description |
---|---|
QueryTermCount create(OpsScorerInitParams params) | Creates a QueryTermCount object. |
QueryTermCount create(OpsScorerInitParams params, CString indexName) | Creates a QueryTermCount object and calculates the number of terms in a specific index. |
double evaluate(OpsScoreParams params) | Calculates the number of query terms after analysis. |
Function details
QueryTermCount create(OpsScorerInitParams params)
Creates a QueryTermCount object. params: the parameters that are used for initialization. For more information, see OpsScorerInitParams.
QueryTermCount create(OpsScorerInitParams params, CString indexName)
Creates a QueryTermCount object and calculates the number of terms in a specific index. params: the parameters that are used for initialization. For more information, see OpsScorerInitParams. indexName: the name of the index for which you want to calculate the number of terms. The name must be a constant.
double evaluate(OpsScoreParams params)
Calculates the number of terms after analysis. params: the parameters that are used for score calculation. For more information, see OpsScoreParams. 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.querymatch.QueryTermCount;
class BasicSimilarityScorer {
QueryTermCount _f1;
boolean init(OpsScorerInitParams params) {
_f1 = QueryTermCount.create(params);
return true;
}
double score(OpsScoreParams params) {
OpsDoc doc = params.getDoc();
float s1 = _f1.evaluate(params);
doc.trace("s1 ", s1);
return s1;
}
};