Add transform to document before index

Closes #6566
This can just be `Map<String, ?>` since Object is the base class.