Skip to content

Allow different decay values depending on the score function #78887

@matiassalles99

Description

@matiassalles99

Currently, when setting a decay value on a score function, you can only set a value between 0 and 1 exclusively, independently of the score function you're using.

// elasticsearch/server/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionBuilder.java
protected DecayFunctionBuilder(String fieldName, Object origin, Object scale, Object offset, double decay) {
        if (fieldName == null) {
            throw new IllegalArgumentException("decay function: field name must not be null");
        }
        if (scale == null) {
            throw new IllegalArgumentException("decay function: scale must not be null");
        }
        if (decay <= 0 || decay >= 1.0) {
            throw new IllegalStateException("decay function: decay must be in range 0..1!");
        }
// ....

This makes sense with gauss and exp score functions, since they use ln(decay) in their formula, and ln(0) does not exist.
But when using linear functions the decay should be allowed to be 0, since the formula would not result in a division by 0.
image

If you have any suggestions over the best way on how to tackle this, I'm open to go ahead and code it.

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions