elasticsearch FunctionScore Java API

elasticsearch FunctionScore java API
1、使用script
FunctionScoreQueryBuilder query =
QueryBuilders.functionScoreQuery(queryBuilder
).add(ScoreFunctionBuilders.scriptFunction(
new Script(–对应的脚本文件– ).scoreMode(“sum”)
.boostMode(CombineFunction.SUM);
2、fieldValueFactor 查询
public FunctionScoreQueryBuilder sortByFucntion(QueryBuilder queryBuilder) {
FunctionScoreQueryBuilder query = QueryBuilders.functionScoreQuery(queryBuilder,
ScoreFunctionBuilders.fieldValueFactorFunction(查询字段).modifier(Modifier.LN1P).factor(1f)).boostMode(“sum”); .add(ScoreFunctionBuilders.fieldValueFactorFunction(查询字段).modifier(Modifier.RECIPROCAL).factor(1)).boostMode(“sum”);
return query;
}

你可能感兴趣的:(elasticsearch)