Add environment variable to skip repository initialization.

Original Pull Request #2878
Closes #2876
This commit is contained in:
Peter-Josef Meisch 2024-03-24 17:37:11 +01:00 committed by GitHub
parent aa27bbec27
commit 7f178238db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View File

@ -82,10 +82,12 @@ public class SimpleElasticsearchRepository<T, ID> implements ElasticsearchReposi
this.entityClass = this.entityInformation.getJavaType();
this.indexOperations = operations.indexOps(this.entityClass);
if (shouldCreateIndexAndMapping() && !indexOperations.exists()) {
indexOperations.createWithMapping();
} else if (shouldAlwaysWriteMapping()) {
indexOperations.putMapping();
if (!"true".equals(System.getenv("SPRING_DATA_ELASTICSEARCH_SKIP_REPOSITORY_INIT"))) {
if (shouldCreateIndexAndMapping() && !indexOperations.exists()) {
indexOperations.createWithMapping();
} else if (shouldAlwaysWriteMapping()) {
indexOperations.putMapping();
}
}
}

View File

@ -61,7 +61,9 @@ public class SimpleReactiveElasticsearchRepository<T, ID> implements ReactiveEla
this.operations = operations;
this.indexOperations = operations.indexOps(entityInformation.getJavaType());
createIndexAndMappingIfNeeded();
if (!"true".equals(System.getenv("SPRING_DATA_ELASTICSEARCH_SKIP_REPOSITORY_INIT"))) {
createIndexAndMappingIfNeeded();
}
}
private void createIndexAndMappingIfNeeded() {