文档

QueryTermCount

更新时间:

简介

计算查询词分词词组个数。

函数列表

函数原型

函数简介

QueryTermCount create(OpsScorerInitParams params)

创建QueryTermCount

QueryTermCount create(OpsScorerInitParams params, CString indexName)

创建QueryTermCount,计算指定索引下的查询词个数

double evaluate(OpsScoreParams params)

计算查询词分词词组个数

函数详情

QueryTermCount create(OpsScorerInitParams params)

创建QueryTermCount对象。参数列表:params — scorer初始化参数,详情请参考OpsScorerInitParams手册

QueryTermCount create(OpsScorerInitParams params, CString indexName)

创建QueryTermCount对象,只返回指定索引的term个数。参数列表:params — scorer初始化参数,详情请参考OpsScorerInitParams手册。indexName — 需要计算term个数的索引名称,必须为常量。

double evaluate(OpsScoreParams params)

计算查询词分词词组个数。参数列表:params — 算分输入参数,详情请参考OpsScoreParams手册。代码示例:

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;
    }
};
  • 本页导读 (0)