Skip to content

Commit 81cad80

Browse files
authored
Update mapping-index-management.adoc
added clarity around @CompoundIndexes use Signed-off-by: Kenny <[email protected]>
1 parent ceac2b8 commit 81cad80

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/main/antora/modules/ROOT/pages/mongodb/mapping/mapping-index-management.adoc

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,24 @@ public class Person {
118118

119119
[TIP]
120120
====
121-
`@CompoundIndex` is repeatable using `@CompoundIndexes` as its container.
122-
121+
`@CompoundIndex` is repeatable using `@CompoundIndexes` as its container, or can simply be declared several times on the same Element, implicitly generating this container annotation.
122+
[source,java]
123+
----
124+
@Document
125+
@CompoundIndexes({
126+
@CompoundIndex(name = "cmp-idx-one", def = "{'firstname': 1, 'lastname': -1}")
127+
@CompoundIndex(name = "cmp-idx-two", def = "{'address.city': -1, 'address.street': 1}")
128+
})
129+
public class Person {
130+
// ...
131+
}
132+
----
123133
[source,java]
124134
----
125135
@Document
126136
@CompoundIndex(name = "cmp-idx-one", def = "{'firstname': 1, 'lastname': -1}")
127137
@CompoundIndex(name = "cmp-idx-two", def = "{'address.city': -1, 'address.street': 1}")
128138
public class Person {
129-
130-
String firstname;
131-
String lastname;
132-
133-
Address address;
134-
135139
// ...
136140
}
137141
----

0 commit comments

Comments
 (0)