refactor(基础模块): 优化es索引配置,增加拓展性。 (#526)
This commit is contained in:
parent
fee733672c
commit
1ad1e448ee
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue