@Target(value={ANNOTATION_TYPE,FIELD}) @Retention(value=RUNTIME) public @interface Indexed
Modifier and Type | Optional Element and Description |
---|---|
boolean |
background
If true the index will be created in the background.
|
String |
collection
Deprecated.
The collection name is derived from the domain type. Fixing the collection via this attribute might
result in broken definitions. Will be removed in 1.7.
|
IndexDirection |
direction |
boolean |
dropDups |
int |
expireAfterSeconds
Configures the number of seconds after which the collection should expire.
|
String |
name
Index name.
|
boolean |
sparse
If set to true index will skip over any document that is missing the indexed field.
|
boolean |
unique
If set to true reject all documents that contain a duplicate value for the indexed field.
|
boolean |
useGeneratedName
If set to true then MongoDB will ignore the given index name and instead generate a new name.
|
public abstract boolean unique
http://docs.mongodb.org/manual/core/index-unique/
public abstract IndexDirection direction
public abstract boolean sparse
http://docs.mongodb.org/manual/core/index-sparse/
public abstract boolean dropDups
http://docs.mongodb.org/manual/core/index-creation/#index-creation-duplicate-dropping
public abstract String name
@Document
class Root {
Hybrid hybrid;
Nested nested;
}
@Document
class Hybrid {
@Indexed(name="index") String h1;
}
class Nested {
@Indexed(name="index") String n1;
}
resolves in the following index structures
db.root.createIndex( { hybrid.h1: 1 } , { name: "hybrid.index" } )
db.root.createIndex( { nested.n1: 1 } , { name: "nested.index" } )
db.hybrid.createIndex( { h1: 1} , { name: "index" } )
public abstract boolean useGeneratedName
@Deprecated public abstract String collection
Copyright © 2011-2015–2017 Pivotal Software, Inc.. All rights reserved.