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.hutool.core.bean.BeanUtil;
|
||||||
import cn.lili.elasticsearch.config.ElasticsearchProperties;
|
import cn.lili.elasticsearch.config.ElasticsearchProperties;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.assertj.core.api.Assertions;
|
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.action.ActionListener;
|
import org.elasticsearch.action.ActionListener;
|
||||||
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
|
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
|
||||||
@ -89,14 +88,16 @@ public abstract class BaseElasticsearchService {
|
|||||||
try {
|
try {
|
||||||
CreateIndexRequest request = new CreateIndexRequest(index);
|
CreateIndexRequest request = new CreateIndexRequest(index);
|
||||||
//Settings for this 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);
|
CreateIndexResponse createIndexResponse = client.indices().create(request, COMMON_OPTIONS);
|
||||||
createMapping(index);
|
createMapping(index);
|
||||||
log.info(" whether all of the nodes have acknowledged the request : {}", createIndexResponse.isAcknowledged());
|
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());
|
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) {
|
} catch (Exception e) {
|
||||||
log.error("创建索引错误",e);
|
log.error("创建索引错误",e);
|
||||||
throw new ElasticsearchException("创建索引 {" + index + "} 失败:" + e.getMessage());
|
throw new ElasticsearchException("创建索引 {" + index + "} 失败:" + e.getMessage());
|
||||||
@ -342,7 +343,7 @@ public abstract class BaseElasticsearchService {
|
|||||||
PutMappingRequest request = new PutMappingRequest(index)
|
PutMappingRequest request = new PutMappingRequest(index)
|
||||||
.source(source, XContentType.JSON);
|
.source(source, XContentType.JSON);
|
||||||
CountDownLatch latch = new CountDownLatch(1);
|
CountDownLatch latch = new CountDownLatch(1);
|
||||||
AtomicReference response = new AtomicReference<AcknowledgedResponse>();
|
AtomicReference<AcknowledgedResponse> response = new AtomicReference<>();
|
||||||
client.indices().putMappingAsync(
|
client.indices().putMappingAsync(
|
||||||
request,
|
request,
|
||||||
RequestOptions.DEFAULT,
|
RequestOptions.DEFAULT,
|
||||||
@ -359,7 +360,6 @@ public abstract class BaseElasticsearchService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
latch.await(10, TimeUnit.SECONDS);
|
latch.await(10, TimeUnit.SECONDS);
|
||||||
Assertions.assertThat(((AcknowledgedResponse) response.get()).isAcknowledged()).isTrue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user