java.lang.Object
org.springframework.data.mongodb.core.index.Index
All Implemented Interfaces:
IndexDefinition
Direct Known Subclasses:
CompoundIndexDefinition, WildcardIndex

public class Index extends Object implements IndexDefinition
Author:
Oliver Gierke, Christoph Strobl, Mark Paluch
  • Constructor Details

    • Index

      public Index()
    • Index

      public Index(String key, org.springframework.data.domain.Sort.Direction direction)
  • Method Details

    • on

      public Index on(String key, org.springframework.data.domain.Sort.Direction direction)
    • named

      public Index named(String name)
    • unique

      public Index unique()
      Reject all documents that contain a duplicate value for the indexed field.
      Returns:
      this.
      See Also:
    • sparse

      public Index sparse()
      Skip over any document that is missing the indexed field.
      Returns:
      this.
      See Also:
    • background

      public Index background()
      Build the index in background (non blocking).
      Returns:
      this.
      Since:
      1.5
    • hidden

      public Index hidden()
      Hidden indexes are not visible to the query planner and cannot be used to support a query.
      Returns:
      this.
      Since:
      4.1
      See Also:
    • expire

      public Index expire(long value)
      Specifies TTL in seconds.
      Parameters:
      value -
      Returns:
      this.
      Since:
      1.5
    • expire

      public Index expire(Duration timeout)
      Specifies the TTL.
      Parameters:
      timeout - must not be null.
      Returns:
      this.
      Throws:
      IllegalArgumentException - if given timeout is null.
      Since:
      2.2
    • expire

      public Index expire(long value, TimeUnit unit)
      Specifies TTL with given TimeUnit.
      Parameters:
      value -
      unit - must not be null.
      Returns:
      this.
      Since:
      1.5
    • partial

      public Index partial(@Nullable IndexFilter filter)
      Only index the documents in a collection that meet a specified filter expression.
      Parameters:
      filter - can be null.
      Returns:
      this.
      Since:
      1.10
      See Also:
    • collation

      public Index collation(@Nullable Collation collation)
      Set the Collation to specify language-specific rules for string comparison, such as rules for lettercase and accent marks.
      NOTE: Only queries using the same Collation as the Index actually make use of the index.
      Parameters:
      collation - can be null.
      Returns:
      this.
      Since:
      2.0
    • getIndexKeys

      public org.bson.Document getIndexKeys()
      Description copied from interface: IndexDefinition
      Get the Document containing properties covered by the index.
      Specified by:
      getIndexKeys in interface IndexDefinition
      Returns:
      never null.
    • getIndexOptions

      public org.bson.Document getIndexOptions()
      Description copied from interface: IndexDefinition
      Get the index properties such as unique,...
      Specified by:
      getIndexOptions in interface IndexDefinition
      Returns:
      never null.
    • toString

      public String toString()
      Overrides:
      toString in class Object