@Documented @Target(value={TYPE,FIELD}) @Retention(value=RUNTIME) public @interface WildcardIndexed
type that is a root level domain entity (one having an
Document annotation) will advise the index creator to create a
wildcard index for it.
@Document
@WildcardIndexed
public class Product {
...
}
db.product.createIndex({ "$**" : 1 } , {})
wildcardProjection can be used to specify keys to in-/exclude in the index.
@Document
@WildcardIndexed(wildcardProjection = "{ 'userMetadata.age' : 0 }")
public class User {
private @Id String id;
private UserMetadata userMetadata;
}
db.user.createIndex(
{ "$**" : 1 },
{ "wildcardProjection" :
{ "userMetadata.age" : 0 }
}
)
Wildcard indexes can also be expressed by adding the annotation directly to the field. Please note that
wildcardProjection is not allowed on nested paths.
@Document
public class User {
private @Id String id;
@WildcardIndexed
private UserMetadata userMetadata;
}
db.user.createIndex({ "userMetadata.$**" : 1 }, {})
| Modifier and Type | Optional Element and Description |
|---|---|
String |
collation
Defines the collation to apply.
|
String |
name
Index name either as plain value or as
template
expression. |
String |
partialFilter
Only index the documents in a collection that meet a specified
filter expression. |
boolean |
useGeneratedName
If set to true then MongoDB will ignore the given index name and instead generate a new name.
|
String |
wildcardProjection
Explicitly specify sub fields to be in-/excluded as a
prasable String. |
public abstract String name
template
expression. public abstract boolean useGeneratedName
public abstract String partialFilter
filter expression. public abstract String wildcardProjection
prasable String.
Copyright © 2011–2022 Pivotal Software, Inc.. All rights reserved.