java.lang.Object
org.springframework.data.mongodb.core.index.Index
org.springframework.data.mongodb.core.index.WildcardIndex
- All Implemented Interfaces:
IndexDefinition
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
- Since:
- 3.3
- Author:
- Christoph Strobl
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new instance ofWildcardIndexusing$**.WildcardIndex(String path) Create a new instance ofWildcardIndexfor the given path. -
Method Summary
Modifier and TypeMethodDescriptionexpire(long seconds) ttl option is not supported.ttl option is not supported.ttl option is not supported.org.bson.DocumentGet theDocumentcontaining properties covered by the index.org.bson.DocumentGet the index properties such as unique,...Include the_idfield in wildcardProjection.Set the index name to use.unique()Unique option is not supported.wildcardProjection(Map<String, Object> includeExclude) Set the fields to be in-/excluded from indexing viawildcardProjection.wildcardProjectionExclude(String... paths) Add fields to be excluded from indexing viawildcardProjection.wildcardProjectionInclude(String... paths) Add fields to be included from indexing viawildcardProjection.
-
Constructor Details
-
WildcardIndex
public WildcardIndex()Create a new instance ofWildcardIndexusing$**. -
WildcardIndex
Create a new instance ofWildcardIndexfor the given path. If no path is provided the index will be considered a root one using$**.
NOTE:wildcardProjectionInclude(String...),wildcardProjectionExclude(String...)can only be used for top level index definitions having an empty or null path.- Parameters:
path- can be null. If null all fields will be indexed.
-
-
Method Details
-
includeId
Include the_idfield in wildcardProjection.- Returns:
- this.
-
named
Set the index name to use. -
unique
Unique option is not supported.- Overrides:
uniquein classIndex- Returns:
- this.
- Throws:
UnsupportedOperationException- not supported for wildcard indexes.- See Also:
-
expire
ttl option is not supported.- Overrides:
expirein classIndex- Returns:
- this.
- Throws:
UnsupportedOperationException- not supported for wildcard indexes.
-
expire
ttl option is not supported.- Overrides:
expirein classIndextimeUnit- must not be null.- Returns:
- this.
- Throws:
UnsupportedOperationException- not supported for wildcard indexes.
-
expire
ttl option is not supported.- Overrides:
expirein classIndex- Parameters:
duration- must not be null.- Returns:
- this.
- Throws:
UnsupportedOperationException- not supported for wildcard indexes.
-
wildcardProjectionInclude
Add fields to be included from indexing viawildcardProjection.
This option is only allowed ontop levelwildcard indexes.- Parameters:
paths- must not be null.- Returns:
- this.
-
wildcardProjectionExclude
Add fields to be excluded from indexing viawildcardProjection.
This option is only allowed ontop levelwildcard indexes.- Parameters:
paths- must not be null.- Returns:
- this.
-
wildcardProjection
Set the fields to be in-/excluded from indexing viawildcardProjection.
This option is only allowed ontop levelwildcard indexes.- Parameters:
includeExclude- must not be null.- Returns:
- this.
-
getIndexKeys
public org.bson.Document getIndexKeys()Description copied from interface:IndexDefinitionGet theDocumentcontaining properties covered by the index.- Specified by:
getIndexKeysin interfaceIndexDefinition- Overrides:
getIndexKeysin classIndex- Returns:
- never null.
-
getIndexOptions
public org.bson.Document getIndexOptions()Description copied from interface:IndexDefinitionGet the index properties such as unique,...- Specified by:
getIndexOptionsin interfaceIndexDefinition- Overrides:
getIndexOptionsin classIndex- Returns:
- never null.
-