public final class Indexes extends Object
collection.createIndex(compoundIndex(ascending("x"), descending("y")));
Modifier and Type | Method | Description |
---|---|---|
static Bson |
ascendingโ(String... fieldNames) |
Create an index key for an ascending index on the given fields.
|
static Bson |
ascendingโ(List<String> fieldNames) |
Create an index key for an ascending index on the given fields.
|
static Bson |
compoundIndexโ(List<? extends Bson> indexes) |
compound multiple index specifications.
|
static Bson |
compoundIndexโ(Bson... indexes) |
create a compound index specifications.
|
static Bson |
descendingโ(String... fieldNames) |
Create an index key for an ascending index on the given fields.
|
static Bson |
descendingโ(List<String> fieldNames) |
Create an index key for an ascending index on the given fields.
|
static Bson |
geo2dโ(String fieldName) |
Create an index key for a 2d index on the given field.
|
static Bson |
geo2dsphereโ(String... fieldNames) |
Create an index key for an 2dsphere index on the given fields.
|
static Bson |
geo2dsphereโ(List<String> fieldNames) |
Create an index key for an ascending index on the given fields.
|
static Bson |
geoHaystackโ(String fieldName,
Bson additional) |
Create an index key for a geohaystack index on the given field.
|
static Bson |
hashedโ(String fieldName) |
Create an index key for a hashed index on the given field.
|
static Bson |
textโ() |
Create an index key for a text index on every field that contains string data.
|
static Bson |
textโ(String fieldName) |
Create an index key for a text index on the given field.
|
public static Bson ascendingโ(String... fieldNames)
fieldNames
- the field names, which must contain at least onepublic static Bson ascendingโ(List<String> fieldNames)
fieldNames
- the field names, which must contain at least onepublic static Bson descendingโ(String... fieldNames)
fieldNames
- the field names, which must contain at least onepublic static Bson descendingโ(List<String> fieldNames)
fieldNames
- the field names, which must contain at least onepublic static Bson geo2dsphereโ(String... fieldNames)
fieldNames
- the field names, which must contain at least onepublic static Bson geo2dsphereโ(List<String> fieldNames)
fieldNames
- the field names, which must contain at least onepublic static Bson geo2dโ(String fieldName)
Note: A 2d index is for data stored as points on a two-dimensional plane. The 2d index is intended for legacy coordinate pairs used in MongoDB 2.2 and earlier.
fieldName
- the field to create a 2d index onpublic static Bson geoHaystackโ(String fieldName, Bson additional)
Note: For queries that use spherical geometry, a 2dsphere index is a better option than a haystack index. 2dsphere indexes allow field reordering; geoHaystack indexes require the first field to be the location field. Also, geoHaystack indexes are only usable via commands and so always return all results at once..
fieldName
- the field to create a geoHaystack index onadditional
- the additional field that forms the geoHaystack index keypublic static Bson textโ(String fieldName)
fieldName
- the field to create a text index onpublic static Bson textโ()
public static Bson hashedโ(String fieldName)
fieldName
- the field to create a hashed index onpublic static Bson compoundIndexโ(Bson... indexes)
indexes
- the index specificationspublic static Bson compoundIndexโ(List<? extends Bson> indexes)
indexes
- the index specifications