Polishing.

This commit is contained in:
Peter-Josef Meisch 2024-03-24 18:46:04 +01:00
parent 7f178238db
commit 33973ec839
No known key found for this signature in database
GPG Key ID: DE108246970C7708
2 changed files with 11 additions and 6 deletions

View File

@ -83,11 +83,16 @@ public class SimpleElasticsearchRepository<T, ID> implements ElasticsearchReposi
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();
}
createIndexAndMappingIfNeeded();
}
}
public void createIndexAndMappingIfNeeded() {
if (shouldCreateIndexAndMapping() && !indexOperations.exists()) {
indexOperations.createWithMapping();
} else if (shouldAlwaysWriteMapping()) {
indexOperations.putMapping();
}
}

View File

@ -66,7 +66,7 @@ public class SimpleReactiveElasticsearchRepository<T, ID> implements ReactiveEla
}
}
private void createIndexAndMappingIfNeeded() {
public void createIndexAndMappingIfNeeded() {
var blockingIndexOperations = blocking(indexOperations);