最近想要修改调整一下ElasticSearch里面Doc的Score,于是在ES官网查阅了一下,相关的介绍和说明还是非常详细的,能做的修改调整也还是比较多的,需要根据具体的情形去选择相应的方式做合适的调整修改,这里做个简单的记录,以便后续使用方便。
相关解释描述可以参考连接:
https://www.elastic.co/guide/cn/elasticsearch/guide/current/controlling-relevance.html
https://www.elastic.co/guide/cn/elasticsearch/guide/current/function-score-query.html
https://www.elastic.co/guide/cn/elasticsearch/guide/current/boosting-by-popularity.html
https://www.elastic.co/guide/cn/elasticsearch/guide/current/function-score-filters.html
https://www.elastic.co/guide/cn/elasticsearch/guide/current/random-scoring.html
https://www.elastic.co/guide/cn/elasticsearch/guide/current/decay-functions.html
https://www.elastic.co/guide/cn/elasticsearch/guide/current/script-score.html
以下是API操作的部分记录:
ScoreFunctionBuilder scoreFunctionBuilder =
ScoreFunctionBuilders.fieldValueFactorFunction(fieldName)
.factor(boostFactor).modifier(modifier).missing(missing).setWeight(weight);
线性衰减函数 一旦直线与横轴 0 相交,所有其他值的评分都是 0.0
ScoreFunctionBuilders.linearDecayFunction(fieldName, origin, scale)
.setDecay(decay).setOffset(offset).setWeight(weight)
指数衰减函数 先剧烈衰减然后变缓
ScoreFunctionBuilders.exponentialDecayFunction(fieldName, o