Class WildcardIndex

java.lang.Object
org.springframework.data.mongodb.core.index.Index
org.springframework.data.mongodb.core.index.WildcardIndex
All Implemented Interfaces:
IndexDefinition

public class WildcardIndex extends Index
WildcardIndex is a specific Index that can be used to include all fields into an index based on the $**" : 1 pattern on a root object (the one typically carrying the Document annotation). On those it is possible to use wildcardProjectionInclude(String...) and wildcardProjectionExclude(String...) to define specific paths for in-/exclusion.
It can also be used to define an index on a specific field path and its subfields, e.g. "path.to.field.$**" : 1.
Note that wildcardProjections are not allowed in this case.
LIMITATIONS
  • Unique and ttl options are not supported.
  • Keys used for sharding must not be included
  • Cannot be used to generate any type of geo index.
Since:
3.3
Author:
Christoph Strobl
See Also:
  • Constructor Details

  • Method Details

    • includeId

      public WildcardIndex includeId()
      Include the _id field in wildcardProjection.
      Returns:
      this.
    • named

      public WildcardIndex named(String name)
      Set the index name to use.
      Overrides:
      named in class Index
      Parameters:
      name -
      Returns:
      this.
    • unique

      public Index unique()
      Unique option is not supported.
      Overrides:
      unique in class Index
      Returns:
      this.
      Throws:
      UnsupportedOperationException - not supported for wildcard indexes.
      See Also:
    • expire

      public Index expire(long seconds)
      ttl option is not supported.
      Overrides:
      expire in class Index
      Returns:
      this.
      Throws:
      UnsupportedOperationException - not supported for wildcard indexes.
    • expire

      public Index expire(long value, TimeUnit timeUnit)
      ttl option is not supported.
      Overrides:
      expire in class Index
      timeUnit - must not be null.
      Returns:
      this.
      Throws:
      UnsupportedOperationException - not supported for wildcard indexes.
    • expire

      public Index expire(Duration duration)
      ttl option is not supported.
      Overrides:
      expire in class Index
      Parameters:
      duration - must not be null.
      Returns:
      this.
      Throws:
      UnsupportedOperationException - not supported for wildcard indexes.
    • wildcardProjectionInclude

      public WildcardIndex wildcardProjectionInclude(String... paths)
      Add fields to be included from indexing via wildcardProjection.
      This option is only allowed on top level wildcard indexes.
      Parameters:
      paths - must not be null.
      Returns:
      this.
    • wildcardProjectionExclude

      public WildcardIndex wildcardProjectionExclude(String... paths)
      Add fields to be excluded from indexing via wildcardProjection.
      This option is only allowed on top level wildcard indexes.
      Parameters:
      paths - must not be null.
      Returns:
      this.
    • wildcardProjection

      public WildcardIndex wildcardProjection(Map<String,Object> includeExclude)
      Set the fields to be in-/excluded from indexing via wildcardProjection.
      This option is only allowed on top level wildcard indexes.
      Parameters:
      includeExclude - must not be null.
      Returns:
      this.
    • 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
      Overrides:
      getIndexKeys in class Index
      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
      Overrides:
      getIndexOptions in class Index
      Returns:
      never null.