@Override
public final MappingSource getMappingSource() {
try {
if (_mapping == null || isDynamicMapping()) {
Builder mapperBuilder = new RootObjectMapper.Builder(getTypeAlias());
buildMapping(mapperBuilder);
XContentBuilder contentBuilder = JsonXContent.contentBuilder();
contentBuilder.startObject();
mapperBuilder.build(new BuilderContext(null, new ContentPath())).toXContent(contentBuilder,
EMPTY_PARAMS, new ToXContent() {
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params)
throws IOException {