public function addFunction(
        string $functionType,
        $functionParams,
        AbstractQuery $filter = null,
        float $weight = null
    ): self {
        $function = [
            $functionType => $functionParams,
        ];

        if (null !== $filter) {
            $function['filter'] = $filter;
        }

        if (null !== $weight) {
            $function['weight'] = $weight;
        }

        $this->_functions[] = $function;

        return $this;
    }