public function addDecayFunction(
        string $function,
        string $field,
        string $origin,
        string $scale,
        string $offset = null,
        float $decay = null,
        float $weight = null,
        AbstractQuery $filter = null,
        string $multiValueMode = null
    ) {
        $functionParams = [
            $field => [
                'origin' => $origin,
                'scale' => $scale,
            ],
        ];
        if (null !== $offset) {
            $functionParams[$field]['offset'] = $offset;
        }
        if (null !== $decay) {
            $functionParams[$field]['decay'] = $decay;
        }

        if (null !== $multiValueMode) {
            $functionParams['multi_value_mode'] = $multiValueMode;
        }

        return $this->addFunction($function, $functionParams, $filter, $weight);
    }