diff --git a/pom.xml b/pom.xml
index b23a16229f..0d92fb4912 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
+ * NOTE: Since MongoDB 4.2 the background flag is ignored by the server if set. * * @return {@literal false} by default. * @see https://docs.mongodb.org/manual/core/indexes/#background-construction + * @deprecated since 5.0 for removal without replacement. */ + @Deprecated(since = "5.0", forRemoval = true) boolean background() default false; /** diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/Index.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/Index.java index 91195a40f4..c6f83e2e73 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/Index.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/Index.java @@ -94,10 +94,15 @@ public Index sparse() { /** * Build the index in background (non blocking). + *
+ * NOTE: Since MongoDB 4.2 the background flag is ignored by the server if set. * * @return this. * @since 1.5 - */@Contract("-> this") + * @deprecated since 5.0 for removal without replacement. + */ + @Deprecated(since = "5.0", forRemoval = true) + @Contract("-> this") public Index background() { this.background = true; diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/Indexed.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/Indexed.java index 0866556c10..de89420c87 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/Indexed.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/Indexed.java @@ -123,11 +123,15 @@ /** * If {@literal true} the index will be created in the background. + *
+ * NOTE: Since MongoDB 4.2 the background flag is ignored by the server if set.
*
* @return {@literal false} by default.
+ * @deprecated since 5.0 for removal without replacement.
* @see https://docs.mongodb.org/manual/core/indexes/#background-construction
*/
+ @Deprecated(since = "5.0", forRemoval = true)
boolean background() default false;
/**
diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexResolverUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexResolverUnitTests.java
index dda16f7849..92cccb38f7 100644
--- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexResolverUnitTests.java
+++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexResolverUnitTests.java
@@ -613,7 +613,7 @@ public void compoundIndexOnSuperClassResolvedCorrectly() {
public void compoundIndexDoesNotSpecifyNameWhenUsingGenerateName() {
List