Class WildcardIndex
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
ConstructorDescriptionCreate a new instance ofWildcardIndex
using$**
.WildcardIndex
(String path) Create a new instance ofWildcardIndex
for 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.Document
Get theDocument
containing properties covered by the index.org.bson.Document
Get the index properties such as unique,...Include the_id
field 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 ofWildcardIndex
using$**
. -
WildcardIndex
Create a new instance ofWildcardIndex
for 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_id
field in wildcardProjection.- Returns:
- this.
-
named
Set the index name to use. -
unique
Unique option is not supported.- Overrides:
unique
in classIndex
- Returns:
- this.
- Throws:
UnsupportedOperationException
- not supported for wildcard indexes.- See Also:
-
expire
ttl option is not supported.- Overrides:
expire
in classIndex
- Returns:
- this.
- Throws:
UnsupportedOperationException
- not supported for wildcard indexes.
-
expire
ttl option is not supported.- Overrides:
expire
in classIndex
timeUnit
- must not be null.- Returns:
- this.
- Throws:
UnsupportedOperationException
- not supported for wildcard indexes.
-
expire
ttl option is not supported.- Overrides:
expire
in 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 level
wildcard indexes.- Parameters:
paths
- must not be null.- Returns:
- this.
-
wildcardProjectionExclude
Add fields to be excluded from indexing viawildcardProjection
.
This option is only allowed ontop level
wildcard 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 level
wildcard indexes.- Parameters:
includeExclude
- must not be null.- Returns:
- this.
-
getIndexKeys
public org.bson.Document getIndexKeys()Description copied from interface:IndexDefinition
Get theDocument
containing properties covered by the index.- Specified by:
getIndexKeys
in interfaceIndexDefinition
- Overrides:
getIndexKeys
in classIndex
- 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 interfaceIndexDefinition
- Overrides:
getIndexOptions
in classIndex
- Returns:
- never null.
-