diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexResolver.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexResolver.java
index 26503508b..7403367bf 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexResolver.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexResolver.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2021 the original author or authors.
+ * Copyright 2014-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,8 @@ import org.springframework.util.Assert;
* Unless specified otherwise the index name will be created out of the keys/path involved in the index.
* {@link TextIndexed} properties are collected into a single index that covers the detected fields.
* {@link java.util.Map} like structures, unless annotated with {@link WildcardIndexed}, are skipped because the
- * {@link java.util.Map.Entry#getKey() map key}, which cannot be resolved from static metadata, needs to be part of the index.
+ * {@link java.util.Map.Entry#getKey() map key}, which cannot be resolved from static metadata, needs to be part of the
+ * index.
*
* @author Christoph Strobl
* @author Thomas Darimont
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexResolver.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexResolver.java
index 28ce6c0f2..8a1daac25 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexResolver.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexResolver.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2021 the original author or authors.
+ * Copyright 2014-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -354,7 +354,7 @@ public class MongoPersistentEntityIndexResolver implements IndexResolver {
indexDefinitionBuilder.withLanguageOverride(persistentProperty.getFieldName());
}
- if(persistentProperty.isMap()) {
+ if (persistentProperty.isMap()) {
return;
}
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 b4f1bcd55..79f65d228 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
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2021 the original author or authors.
+ * Copyright 2014-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -319,7 +319,8 @@ public class MongoPersistentEntityIndexResolverUnitTests {
class IndexOnLevelZeroWithExplicityNamedField {
- @Indexed @Field("customFieldName") String namedProperty;
+ @Indexed
+ @Field("customFieldName") String namedProperty;
}
@Document
@@ -427,7 +428,8 @@ public class MongoPersistentEntityIndexResolverUnitTests {
@Document
class IndexOnMetaAnnotatedField {
- @Field("_name") @IndexedFieldAnnotation String lastname;
+ @Field("_name")
+ @IndexedFieldAnnotation String lastname;
}
/**
@@ -1366,10 +1368,9 @@ public class MongoPersistentEntityIndexResolverUnitTests {
});
assertThat(indices.get(2)).satisfies(it -> {
assertThat(it.getIndexKeys()).containsEntry("withOptions.$**", 1);
- assertThat(it.getIndexOptions()).containsEntry("name",
- "withOptions.idx")
- .containsEntry("collation", new org.bson.Document("locale", "en_US"))
- .containsEntry("partialFilterExpression", new org.bson.Document("$eq", 1));
+ assertThat(it.getIndexOptions()).containsEntry("name", "withOptions.idx")
+ .containsEntry("collation", new org.bson.Document("locale", "en_US"))
+ .containsEntry("partialFilterExpression", new org.bson.Document("$eq", 1));
});
}
@@ -1491,7 +1492,8 @@ public class MongoPersistentEntityIndexResolverUnitTests {
@Document
class SimilarityHolingBean {
- @Indexed @Field("norm") String normalProperty;
+ @Indexed
+ @Field("norm") String normalProperty;
@Field("similarityL") private List listOfSimilarilyNamedEntities = null;
}
@@ -1654,7 +1656,8 @@ public class MongoPersistentEntityIndexResolverUnitTests {
@Document
class WithHashedIndexOnId {
- @HashIndexed @Id String id;
+ @HashIndexed
+ @Id String id;
}
@Document
diff --git a/src/main/asciidoc/reference/mapping.adoc b/src/main/asciidoc/reference/mapping.adoc
index 9ba17cb1f..ab074ba57 100644
--- a/src/main/asciidoc/reference/mapping.adoc
+++ b/src/main/asciidoc/reference/mapping.adoc
@@ -409,9 +409,9 @@ This event guarantees that the context is fully initialized.
Note that at this time other components, especially bean factories might have access to the MongoDB database.
[WARNING]
-===
-`Map` like structures, unless annotated with `@WildcardIndexed`, are skipped by the `IndexResolver` because the _map key_, which cannot be resolved from static metadata, needs to be part of the index definition.
-===
+====
+``Map``-like properties are skipped by the `IndexResolver` unless annotated with `@WildcardIndexed` because the _map key_ must be part of the index definition. Since the purpose of maps is the usage of dynamic keys and values, the keys cannot be resolved from static mapping metadata.
+====
.Programmatic Index Creation for a single Domain Type
====