Add transform to document before index

Closes #6566
I'll look into it.