refactor(基础模块): 优化es索引配置,增加拓展性。 (#526)

This commit is contained in:
PengyuDeng 2024-06-24 10:34:59 +08:00 committed by GitHub
parent fee733672c
commit 1ad1e448ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -4,6 +4,10 @@ import lombok.*;
import org.elasticsearch.common.settings.Settings;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
@Getter
@Setter
@Builder
@ -16,11 +20,14 @@ public class ElasticSearchIndexProperties {
private int numberOfReplicas = 0;
private Map<String,String> options = new HashMap<>();
public Settings toSettings() {
return Settings.builder()
.put("number_of_shards", Math.max(1, numberOfShards))
.put("number_of_replicas", numberOfReplicas)
.putProperties(options, Function.identity())
.build();
}
}