add elasticsearch setting index.mapping.total_fields.limit
This commit is contained in:
parent
55c9a63301
commit
d838f7f3f0
@ -3,7 +3,6 @@ package cn.lili.elasticsearch;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.lili.elasticsearch.config.ElasticsearchProperties;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
|
||||
@ -89,14 +88,16 @@ public abstract class BaseElasticsearchService {
|
||||
try {
|
||||
CreateIndexRequest request = new CreateIndexRequest(index);
|
||||
//Settings for this index
|
||||
request.settings(Settings.builder().put("index.number_of_shards", elasticsearchProperties.getIndex().getNumberOfShards()).put("index.number_of_replicas", elasticsearchProperties.getIndex().getNumberOfReplicas()));
|
||||
request.settings(Settings.builder()
|
||||
.put("index.number_of_shards", elasticsearchProperties.getIndex().getNumberOfShards())
|
||||
.put("index.number_of_replicas", elasticsearchProperties.getIndex().getNumberOfReplicas())
|
||||
.put("index.mapping.total_fields.limit", 2000));
|
||||
|
||||
//创建索引
|
||||
CreateIndexResponse createIndexResponse = client.indices().create(request, COMMON_OPTIONS);
|
||||
createMapping(index);
|
||||
log.info(" whether all of the nodes have acknowledged the request : {}", createIndexResponse.isAcknowledged());
|
||||
log.info(" Indicates whether the requisite number of shard copies were started for each shard in the index before timing out :{}", createIndexResponse.isShardsAcknowledged());
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
log.error("创建索引错误",e);
|
||||
throw new ElasticsearchException("创建索引 {" + index + "} 失败:" + e.getMessage());
|
||||
@ -342,7 +343,7 @@ public abstract class BaseElasticsearchService {
|
||||
PutMappingRequest request = new PutMappingRequest(index)
|
||||
.source(source, XContentType.JSON);
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
AtomicReference response = new AtomicReference<AcknowledgedResponse>();
|
||||
AtomicReference<AcknowledgedResponse> response = new AtomicReference<>();
|
||||
client.indices().putMappingAsync(
|
||||
request,
|
||||
RequestOptions.DEFAULT,
|
||||
@ -359,7 +360,6 @@ public abstract class BaseElasticsearchService {
|
||||
}
|
||||
});
|
||||
latch.await(10, TimeUnit.SECONDS);
|
||||
Assertions.assertThat(((AcknowledgedResponse) response.get()).isAcknowledged()).isTrue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user