I like the fact that you move that boilerplate code out. Yet I think you can simply keep the refactoring into `getMappingUrl` and drop all the rest here. Instead you can just use the script template as the default template like:

```
final URL defaultMappingUrl;
if (this.index.getName().equals(ScriptService.SCRIPT_INDEX) {
 defaultMappingUrl = getMappingUrl(indexSettings, environment, defaultMappingLocation,"script-index-defaults.json","org/elasticsearch/index/mapper/script-index-defaults.json");
} else {
  defaultMappingUrl = getMappingUrl(indexSettings, environment, defaultMappingLocation,"default-mapping.json","org/elasticsearch/index/mapper/default-mapping.json");
}
```
since we effectively change the default template we can just overload it here. That means we don't need to duplicate the mapping in the code below neither we need to add the if in line 411