From 60179e51e4a85aeea413b9fe571dbf429576f932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Monteiro?= Date: Fri, 8 Aug 2025 22:44:56 +0100 Subject: [PATCH] Fix mapping-index-management.adoc examples. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: André Monteiro --- .../pages/mongodb/mapping/mapping-index-management.adoc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/antora/modules/ROOT/pages/mongodb/mapping/mapping-index-management.adoc b/src/main/antora/modules/ROOT/pages/mongodb/mapping/mapping-index-management.adoc index b094b925d0..94293fd5ba 100644 --- a/src/main/antora/modules/ROOT/pages/mongodb/mapping/mapping-index-management.adoc +++ b/src/main/antora/modules/ROOT/pages/mongodb/mapping/mapping-index-management.adoc @@ -51,6 +51,8 @@ class MyListener{ MappingContext, MongoPersistentProperty> mappingContext = mongoTemplate .getConverter().getMappingContext(); + IndexResolver resolver = new MongoPersistentEntityIndexResolver(mappingContext); + // consider only entities that are annotated with @Document mappingContext.getPersistentEntities() .stream() @@ -123,8 +125,10 @@ public class Person { [source,java] ---- @Document -@CompoundIndex(name = "cmp-idx-one", def = "{'firstname': 1, 'lastname': -1}") -@CompoundIndex(name = "cmp-idx-two", def = "{'address.city': -1, 'address.street': 1}") +@CompoundIndexes({ + @CompoundIndex(name = "cmp-idx-one", def = "{'firstname': 1, 'lastname': -1}"), + @CompoundIndex(name = "cmp-idx-two", def = "{'address.city': -1, 'address.street': 1}") +}) public class Person { String firstname;