Add transform to document before index

Closes #6566
Can we avoid duplicating the code for the conversion by doing eg.

```java
Map<String, Object> sourceAsMap = null;
final boolean sourceFiltering = sourceFieldMapper.includes().length > 0 || sourceFieldMapper.excludes().length > 0;
if (fetchSourceContext.transformSource() || sourceFiltering) {
    Tuple<XContentType, Map<String, Object>> typeMapTuple = XContentHelper.convertToMap(source.source, true);
    sourceContentType = typeMapTuple.v1();
    sourceAsMap = typeMapTuple.v2();
}
if (fetchSourceContext.transformSource()) {
    sourceAsMap = docMapper.transformSourceAsMap(sourceAsMap);
}
if (sourceFiltering) {
    sourceAsMap = XContentMapValues.filter(sourceAsMap, sourceFieldMapper.includes(), sourceFieldMapper.excludes());
}
```