diff --git a/pom.xml b/pom.xml
index 3daab4d790..56b5c00be7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.springframework.data
spring-data-mongodb-parent
- 5.0.0-SNAPSHOT
+ 5.0.x-GH-5010-SNAPSHOT
pom
Spring Data MongoDB
diff --git a/spring-data-mongodb-distribution/pom.xml b/spring-data-mongodb-distribution/pom.xml
index fc88571622..d6177ac09e 100644
--- a/spring-data-mongodb-distribution/pom.xml
+++ b/spring-data-mongodb-distribution/pom.xml
@@ -15,7 +15,7 @@
org.springframework.data
spring-data-mongodb-parent
- 5.0.0-SNAPSHOT
+ 5.0.x-GH-5010-SNAPSHOT
../pom.xml
diff --git a/spring-data-mongodb/pom.xml b/spring-data-mongodb/pom.xml
index 6f34da5660..a3c1b9b28a 100644
--- a/spring-data-mongodb/pom.xml
+++ b/spring-data-mongodb/pom.xml
@@ -13,7 +13,7 @@
org.springframework.data
spring-data-mongodb-parent
- 5.0.0-SNAPSHOT
+ 5.0.x-GH-5010-SNAPSHOT
../pom.xml
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultIndexOperations.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultIndexOperations.java
index 24d22bd80a..69c6be96e1 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultIndexOperations.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultIndexOperations.java
@@ -116,7 +116,7 @@ public DefaultIndexOperations(MongoOperations mongoOperations, String collection
@Override
@SuppressWarnings("NullAway")
- public String ensureIndex(IndexDefinition indexDefinition) {
+ public String createIndex(IndexDefinition indexDefinition) {
return execute(collection -> {
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultReactiveIndexOperations.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultReactiveIndexOperations.java
index 69ade2e163..4c4ad18b4d 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultReactiveIndexOperations.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultReactiveIndexOperations.java
@@ -84,7 +84,7 @@ public DefaultReactiveIndexOperations(ReactiveMongoOperations mongoOperations, S
@Override
@SuppressWarnings("NullAway")
- public Mono ensureIndex(IndexDefinition indexDefinition) {
+ public Mono createIndex(IndexDefinition indexDefinition) {
return mongoOperations.execute(collectionName, collection -> {
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexOperations.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexOperations.java
index 88e6d7a815..1f8ddf5d7d 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexOperations.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexOperations.java
@@ -36,19 +36,20 @@ public interface IndexOperations {
* @deprecated since 4.5, in favor of {@link #createIndex(IndexDefinition)}.
*/
@Deprecated(since = "4.5", forRemoval = true)
- String ensureIndex(IndexDefinition indexDefinition);
+ default String ensureIndex(IndexDefinition indexDefinition) {
+ return createIndex(indexDefinition);
+ }
/**
- * Create the index for the provided {@link IndexDefinition} exists for the collection indicated by the entity class.
- * If not it will be created.
+ * Create the index for the provided {@link IndexDefinition} for the collection indicated by the entity class. If the
+ * index does not exist it will be created. Might error if the collection already defines an index with the same name
+ * but different settings.
*
* @param indexDefinition must not be {@literal null}.
* @return the index name.
* @since 4.5
*/
- default String createIndex(IndexDefinition indexDefinition) {
- return ensureIndex(indexDefinition);
- }
+ String createIndex(IndexDefinition indexDefinition);
/**
* Alters the index with given {@literal name}.
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexOperationsAdapter.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexOperationsAdapter.java
index 613a3dc4f4..5dc33e25dd 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexOperationsAdapter.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexOperationsAdapter.java
@@ -41,8 +41,8 @@ static IndexOperationsAdapter blocking(ReactiveIndexOperations reactiveIndexOper
return new IndexOperationsAdapter() {
@Override
- public String ensureIndex(IndexDefinition indexDefinition) {
- return reactiveIndexOperations.ensureIndex(indexDefinition).block();
+ public String createIndex(IndexDefinition indexDefinition) {
+ return reactiveIndexOperations.createIndex(indexDefinition).block();
}
@Override
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/ReactiveIndexOperations.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/ReactiveIndexOperations.java
index 15b110c08a..4978628652 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/ReactiveIndexOperations.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/ReactiveIndexOperations.java
@@ -36,19 +36,20 @@ public interface ReactiveIndexOperations {
* @deprecated since 4.5, in favor of {@link #createIndex(IndexDefinition)}.
*/
@Deprecated(since = "4.5", forRemoval = true)
- Mono ensureIndex(IndexDefinition indexDefinition);
+ default Mono ensureIndex(IndexDefinition indexDefinition) {
+ return createIndex(indexDefinition);
+ }
/**
- * Create the index for the provided {@link IndexDefinition} exists for the collection indicated by the entity class.
- * If not it will be created.
+ * Create the index for the provided {@link IndexDefinition} for the collection indicated by the entity class. If the
+ * index does not exist it will be created. Might error if the collection already defines an index with the same name
+ * but different settings.
*
* @param indexDefinition must not be {@literal null}.
* @return the index name.
* @since 4.5
*/
- default Mono createIndex(IndexDefinition indexDefinition) {
- return ensureIndex(indexDefinition);
- }
+ Mono createIndex(IndexDefinition indexDefinition);
/**
* Alters the index with given {@literal name}.