Class Indexes

java.lang.Object
com.mongodb.client.model.Indexes

@Deprecated(since="2021-05-27") public final class Indexes extends Object
Deprecated.
Usage of this API is not supported in AEM as a Cloud Service.
A factory for defining index keys. A convenient way to use this class is to statically import all of its methods, which allows usage like:
     collection.createIndex(compoundIndex(ascending("x"), descending("y")));
  
Since:
3.1
  • Method Summary

    Modifier and Type
    Method
    Description
    static Bson
    ascending(String... fieldNames)
    Deprecated.
    Create an index key for an ascending index on the given fields.
    static Bson
    ascending(List<String> fieldNames)
    Deprecated.
    Create an index key for an ascending index on the given fields.
    static Bson
    compoundIndex(List<? extends Bson> indexes)
    Deprecated.
    compound multiple index specifications.
    static Bson
    compoundIndex(Bson... indexes)
    Deprecated.
    create a compound index specifications.
    static Bson
    descending(String... fieldNames)
    Deprecated.
    Create an index key for an ascending index on the given fields.
    static Bson
    descending(List<String> fieldNames)
    Deprecated.
    Create an index key for an ascending index on the given fields.
    static Bson
    geo2d(String fieldName)
    Deprecated.
    Create an index key for a 2d index on the given field.
    static Bson
    geo2dsphere(String... fieldNames)
    Deprecated.
    Create an index key for an 2dsphere index on the given fields.
    static Bson
    geo2dsphere(List<String> fieldNames)
    Deprecated.
    Create an index key for an ascending index on the given fields.
    static Bson
    geoHaystack(String fieldName, Bson additional)
    Deprecated.
    Create an index key for a geohaystack index on the given field.
    static Bson
    hashed(String fieldName)
    Deprecated.
    Create an index key for a hashed index on the given field.
    static Bson
    Deprecated.
    Create an index key for a text index on every field that contains string data.
    static Bson
    text(String fieldName)
    Deprecated.
    Create an index key for a text index on the given field.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • ascending

      public static Bson ascending(String... fieldNames)
      Deprecated.
      Create an index key for an ascending index on the given fields.
      Parameters:
      fieldNames - the field names, which must contain at least one
      Returns:
      the index specification
    • ascending

      public static Bson ascending(List<String> fieldNames)
      Deprecated.
      Create an index key for an ascending index on the given fields.
      Parameters:
      fieldNames - the field names, which must contain at least one
      Returns:
      the index specification
    • descending

      public static Bson descending(String... fieldNames)
      Deprecated.
      Create an index key for an ascending index on the given fields.
      Parameters:
      fieldNames - the field names, which must contain at least one
      Returns:
      the index specification
    • descending

      public static Bson descending(List<String> fieldNames)
      Deprecated.
      Create an index key for an ascending index on the given fields.
      Parameters:
      fieldNames - the field names, which must contain at least one
      Returns:
      the index specification
    • geo2dsphere

      public static Bson geo2dsphere(String... fieldNames)
      Deprecated.
      Create an index key for an 2dsphere index on the given fields.
      Parameters:
      fieldNames - the field names, which must contain at least one
      Returns:
      the index specification
    • geo2dsphere

      public static Bson geo2dsphere(List<String> fieldNames)
      Deprecated.
      Create an index key for an ascending index on the given fields.
      Parameters:
      fieldNames - the field names, which must contain at least one
      Returns:
      the index specification
    • geo2d

      public static Bson geo2d(String fieldName)
      Deprecated.
      Create an index key for a 2d index on the given field.

      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.

      Parameters:
      fieldName - the field to create a 2d index on
      Returns:
      the index specification
    • geoHaystack

      public static Bson geoHaystack(String fieldName, Bson additional)
      Deprecated.
      Create an index key for a geohaystack index on the given field.

      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..

      Parameters:
      fieldName - the field to create a geoHaystack index on
      additional - the additional field that forms the geoHaystack index key
      Returns:
      the index specification
    • text

      public static Bson text(String fieldName)
      Deprecated.
      Create an index key for a text index on the given field.
      Parameters:
      fieldName - the field to create a text index on
      Returns:
      the index specification
    • text

      public static Bson text()
      Deprecated.
      Create an index key for a text index on every field that contains string data.
      Returns:
      the index specification
    • hashed

      public static Bson hashed(String fieldName)
      Deprecated.
      Create an index key for a hashed index on the given field.
      Parameters:
      fieldName - the field to create a hashed index on
      Returns:
      the index specification
    • compoundIndex

      public static Bson compoundIndex(Bson... indexes)
      Deprecated.
      create a compound index specifications. If any field names are repeated, the last one takes precedence.
      Parameters:
      indexes - the index specifications
      Returns:
      the compound index specification
    • compoundIndex

      public static Bson compoundIndex(List<? extends Bson> indexes)
      Deprecated.
      compound multiple index specifications. If any field names are repeated, the last one takes precedence.
      Parameters:
      indexes - the index specifications
      Returns:
      the compound index specification