mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-07-04 17:52:11 +00:00
Add environment variable to skip repository initialization.
Original Pull Request #2878 Closes #2876
This commit is contained in:
parent
aa27bbec27
commit
7f178238db
@ -82,12 +82,14 @@ public class SimpleElasticsearchRepository<T, ID> implements ElasticsearchReposi
|
||||
this.entityClass = this.entityInformation.getJavaType();
|
||||
this.indexOperations = operations.indexOps(this.entityClass);
|
||||
|
||||
if (!"true".equals(System.getenv("SPRING_DATA_ELASTICSEARCH_SKIP_REPOSITORY_INIT"))) {
|
||||
if (shouldCreateIndexAndMapping() && !indexOperations.exists()) {
|
||||
indexOperations.createWithMapping();
|
||||
} else if (shouldAlwaysWriteMapping()) {
|
||||
indexOperations.putMapping();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldCreateIndexAndMapping() {
|
||||
|
||||
|
@ -61,8 +61,10 @@ public class SimpleReactiveElasticsearchRepository<T, ID> implements ReactiveEla
|
||||
this.operations = operations;
|
||||
this.indexOperations = operations.indexOps(entityInformation.getJavaType());
|
||||
|
||||
if (!"true".equals(System.getenv("SPRING_DATA_ELASTICSEARCH_SKIP_REPOSITORY_INIT"))) {
|
||||
createIndexAndMappingIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
private void createIndexAndMappingIfNeeded() {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user