exp_decay

更新时间:
复制 MD 格式

Feature functions

You can use feature functions in sort expressions. Most feature functions are supported only in fine sort expressions. You can combine various syntaxes and statements to create powerful sorting features.

If you use a document field as a parameter in a feature function, you must create it as an index or a property as specified in the function's documentation.

exp_decay: Calculate attenuation using an exponential function

1. Usage:

exp_decay(origin, value, scale, decay, offset)

2. Parameters:

  • origin: The origin of the attenuation function. Supports `double` values.

  • value: The value for which to calculate the attenuation. Supports `double` values. This value can be a document field or another expression.

  • scale: The decay scale. Supports `double` values.

  • decay: The degree of attenuation over distance. This optional parameter is a double-precision floating-point number with a default value of 0.000001.

  • offset: The distance from the origin. Attenuation is calculated only for values outside this distance. Supports `double` values. This parameter is optional. The default value is 0.

2. Return value:

Returns a `double` value in the range [0, 1].

4. Scenarios:

This function is similar to `gauss_decay` but uses a different attenuation algorithm.

5. Notes:

  • You must create function parameters 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 automatically set to 0.000001.

  • If `offset` is less than 0, its value is automatically set to 0.