Hi there, I found this similar thread from awhile back: Changing all array elements in scripted field
In that thread, the author uses the "values" property to retrieve all of the values in the array. So in your example, it would be:
def roles = doc["author.roles.name.keyword"].values
Can you try this and let me know if it works for you?
Thanks,
CJ