org.mongodb.morphia.annotations
Annotation Type Index


@Documented
@Inherited
@Retention(value=RUNTIME)
@Target(value=ANNOTATION_TYPE)
public @interface Index

Defines an index

Author:
Scott Hernandez

Optional Element Summary
 boolean background
          Deprecated. use the IndexOptions found in options()
 boolean disableValidation
          Deprecated. use the IndexOptions found in options()
 boolean dropDups
          Deprecated. use the IndexOptions found in options()
 int expireAfterSeconds
          Deprecated. use the IndexOptions found in options()
 Field[] fields
          List of fields to include in the index.
 String name
          Deprecated. use the IndexOptions found in options()
 IndexOptions options
          Options to apply to the index.
 boolean sparse
          Deprecated. use the IndexOptions found in options()
 boolean unique
          Deprecated. use the IndexOptions found in options()
 String value
          Deprecated. use fields()
 

value

public abstract String value
Deprecated. use fields()

List of fields (prepended with "-" for desc; defaults to asc). If a value is defined for fields() this value will be ignored and logged.

Default:
""

fields

public abstract Field[] fields
List of fields to include in the index. At least one field must be defined unless defining a text index. Use of this field implies use of options() and any options defined directly on this annotation will be ignored.

Default:
{}

options

public abstract IndexOptions options
Options to apply to the index. Use of this field will ignore any of the deprecated options defined on Index directly.

Default:
@org.mongodb.morphia.annotations.IndexOptions

name

public abstract String name
Deprecated. use the IndexOptions found in options()

The name of the index to create; default is to let the mongodb create a name (in the form of key1_1/-1_key2_1/-1...)

Default:
""

unique

public abstract boolean unique
Deprecated. use the IndexOptions found in options()

Creates the index as a unique value index; inserting duplicates values in this field will cause errors

Default:
false

dropDups

public abstract boolean dropDups
Deprecated. use the IndexOptions found in options()

Tells the unique index to drop duplicates silently when creating; only the first will be kept

Default:
false

background

public abstract boolean background
Deprecated. use the IndexOptions found in options()

Create the index in the background

Default:
false

sparse

public abstract boolean sparse
Deprecated. use the IndexOptions found in options()

Create the index with the sparse option

Default:
false

disableValidation

public abstract boolean disableValidation
Deprecated. use the IndexOptions found in options()

disables validation for the field name

Default:
false

expireAfterSeconds

public abstract int expireAfterSeconds
Deprecated. use the IndexOptions found in options()

defines the time to live for documents in the collection

Default:
-1