public class FieldValueFactorFunction extends Object
This is an upgraded feature of FieldValueFactor.
FunctionsScoreQuery, and the function's purpose is to score a doc by performing simple arithmetic operations on a specific field (which must be of type long or double).
For example: In the query of a FunctionsScoreQuery, use a match query to find students whose names contain "Ming", but you want to sort the results by height. At this point, this function can be used. Set the fieldName to height, multiply the factor with the height field to control the weight, use modifier to control the scoring algorithm, including operations like squaring, square root, logarithm, etc. The missing parameter is used to set the default value for the field.
Operation example: fieldName: height, factor: 1.2f, modifier: LOG1P, then score = LOG1P(1.2f * height)
| 限定符和类型 | 类和说明 |
|---|---|
static class |
FieldValueFactorFunction.Builder |
static class |
FieldValueFactorFunction.FunctionModifier |
| 构造器和说明 |
|---|
FieldValueFactorFunction() |
FieldValueFactorFunction(String fieldName,
Float factor,
FieldValueFactorFunction.FunctionModifier modifier,
Double missing) |
| 限定符和类型 | 方法和说明 |
|---|---|
Float |
getFactor() |
String |
getFieldName() |
Double |
getMissing() |
FieldValueFactorFunction.FunctionModifier |
getModifier() |
static FieldValueFactorFunction.Builder |
newBuilder() |
void |
setFactor(Float factor) |
void |
setFieldName(String fieldName) |
void |
setMissing(Double missing) |
void |
setModifier(FieldValueFactorFunction.FunctionModifier modifier) |
public FieldValueFactorFunction()
public FieldValueFactorFunction(String fieldName, Float factor, FieldValueFactorFunction.FunctionModifier modifier, Double missing)
public String getFieldName()
public void setFieldName(String fieldName)
public Float getFactor()
public void setFactor(Float factor)
public FieldValueFactorFunction.FunctionModifier getModifier()
public void setModifier(FieldValueFactorFunction.FunctionModifier modifier)
public Double getMissing()
public void setMissing(Double missing)
public static FieldValueFactorFunction.Builder newBuilder()
Copyright © 2025. All Rights Reserved.