Q: Is there any way to force spring not to use/create '_class' field in the mapping? The thing is on production servers we got mapping for Elasticsearch with dynamic set to strict. Currently, we use a rest level client to communicate with Elastisearch, however, we would like to migrate to spring-data-elasticsearch.
Unfortunately, it seems spring data force to use either _class or @TypeAlias which also interfere with the mapping itself. Is any way to use spring-data without _class or @TypeAlias?

A: Currently this is not possible. There is an open issue for that.
Edit 25.04.2021:
this feature will be available from the next version (4.3) on.

A: Ok I have found a workaround for it.
Be aware of using it when your elasticsearch model uses inheritance.
To solve this problem create class like this:
public class CustomMappingEsConverter extends MappingElasticsearchConverter {

public CustomMappingEsConverter(MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext, GenericConversionService conversionService) {
    super(mappingContext, conversionService);
}

@Override
public Document mapObject(@Nullable Object source) {
    Document target = Document.create();
    if (source != null) {
        this.write(source, target);
    }
    target.remove("_class"); // << workaround to remove those _class field in elasticsearch
    return target;
    }
}

And register the bean:
@Configuration
public class MappingEsConfiguration {

    @Bean
    @Primary
    public CustomMappingEsConverter CustomMappingElasticsearchConverter(MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext,
                                                                        GenericConversionService genericConversionService) {
        return new CustomMappingEsConverter(mappingContext, genericConversionService);
    }
}

After this changes I was able to use spring data without additional field _class.
