Skip to content

Commit 8293d36

Browse files
authored
Update mapping-index-management.adoc
Added explicit example and added note about implicit generation.
1 parent ceac2b8 commit 8293d36

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,26 @@ public class Person {
118118

119119
[TIP]
120120
====
121-
`@CompoundIndex` is repeatable using `@CompoundIndexes` as its container.
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.
122122
123+
[source,java]
124+
----
125+
@Document
126+
@CompoundIndexes({
127+
@CompoundIndex(name = "cmp-idx-one", def = "{'firstname': 1, 'lastname': -1}")
128+
@CompoundIndex(name = "cmp-idx-two", def = "{'address.city': -1, 'address.street': 1}")
129+
})
130+
public class Person {
131+
// ...
132+
}
133+
----
123134
[source,java]
124135
----
125136
@Document
126137
@CompoundIndex(name = "cmp-idx-one", def = "{'firstname': 1, 'lastname': -1}")
127138
@CompoundIndex(name = "cmp-idx-two", def = "{'address.city': -1, 'address.street': 1}")
128-
public class Person {
129-
130-
String firstname;
131-
String lastname;
132-
133-
Address address;
134139
140+
public class Person {
135141
// ...
136142
}
137143
----

0 commit comments

Comments
 (0)