SELECT
    user_id, username, email
FROM
    users
ORDER BY
    GREATEST (
        similarity (email, $1),
        similarity (username, $1)
    ) DESC