Feature functions
You can use feature functions in sort expressions. Most feature functions are supported only in fine sort expressions. You can combine various syntax and statements to implement powerful sorting features.
Document fields that are used as parameters in a feature function must be created as an index or a property, as specified in the documentation for that function.
linear_decay: Uses a linear function to calculate attenuation based on the distance between a value and an origin point
1. Usage details:
linear_decay(origin, value, scale, decay, offset)
2. Parameters:
origin: The origin point of the attenuation function. The data type of this parameter is `double`.
value: The value for which to calculate attenuation. This value can be a document field or another expression. The data type of this parameter is `double`.
scale: The degree of attenuation, a double-precision floating-point number.
decay: The attenuation score when the distance is equal to the `scale` value. The data type of this parameter is `double`. This parameter is optional. The default value is 0.000001.
offset: The distance from the origin after which attenuation begins. The data type of this parameter is `double`. This parameter is optional. The default value is 0.
3. Return value:
The function returns a `double` value in the range of [0, 1].
4. Scenarios:
The scenarios are the same as for `gauss_decay`. The only difference is the attenuation algorithm.
5. Notes:
The function parameters must be created as properties.
If `scale` is less than or equal to 0, the function returns 0.
If `decay` is greater than or equal to 1, the function returns 1.
If `decay` is less than or equal to 0, its value is set to 0.000001.
If `offset` is less than 0, its value is set to 0.