class TemplateElasticSearchIndexStrategy extends AbstractElasticSearchIndexStrategy {

    public TemplateElasticSearchIndexStrategy(String id, ReactiveElasticsearchClient client, ElasticSearchIndexProperties properties) {
        super(id, client, properties);
    }

    protected String getTemplate(String index) {
        return wrapIndex(index).concat("_template");
    }

    protected String getAlias(String index) {
        return wrapIndex(index).concat("_alias");
    }

    protected List<String> getIndexPatterns(String index) {
        return Collections.singletonList(wrapIndex(index).concat("*"));
    }

    @Override
    public abstract String getIndexForSave(String index);

    @Override
    public String getIndexForSearch(String index) {
        return getAlias(index);
    }

    @Override
    public Mono<ElasticSearchIndexMetadata> putIndex(ElasticSearchIndexMetadata metadata) {

        return client
            .putTemplate(createIndexTemplateRequest(metadata))
            //修改当前索引
            .then(doPutIndex(metadata.newIndexName(getIndexForSave(metadata.getIndex())), true))
            .thenReturn(metadata.newIndexName(wrapIndex(metadata.getIndex())));
    }

    protected PutIndexTemplateRequest createIndexTemplateRequest(ElasticSearchIndexMetadata metadata) {<FILL_FUNCTION_BODY>}


    @Override
    public Mono<ElasticSearchIndexMetadata> loadIndexMetadata(String index) {
        return client.getTemplate(new GetIndexTemplatesRequest(getTemplate(index)))
                     .filter(resp -> CollectionUtils.isNotEmpty(resp.getIndexTemplates()))
                     .flatMap(resp -> Mono.justOrEmpty(convertMetadata(index, resp
                         .getIndexTemplates()
                         .get(0)
                         .mappings())));
    }
}

        String index = wrapIndex(metadata.getIndex());
        PutIndexTemplateRequest request = new PutIndexTemplateRequest(getTemplate(index));
        request.alias(new Alias(getAlias(index)));
        request.settings(properties.toSettings());
        Map<String, Object> mappingConfig = new HashMap<>();
        mappingConfig.put("properties", createElasticProperties(metadata.getProperties()));
        mappingConfig.put("dynamic_templates", createDynamicTemplates());
        if (client.serverVersion().after(Version.V_7_0_0)) {
            request.mapping(mappingConfig);
        } else {
            request.mapping(Collections.singletonMap("_doc", mappingConfig));
        }
        request.patterns(getIndexPatterns(index));
        return request;
    
<methods>public non-sealed void <init>() <variables>protected org.jetlinks.community.elastic.search.service.reactive.ReactiveElasticsearchClient client,private final non-sealed java.lang.String id,protected org.jetlinks.community.elastic.search.index.ElasticSearchIndexProperties properties