Class Index
java.lang.Object
org.springframework.data.mongodb.core.index.Index
- All Implemented Interfaces:
IndexDefinition
- Direct Known Subclasses:
CompoundIndexDefinition, WildcardIndex
- Author:
- Oliver Gierke, Christoph Strobl, Mark Paluch
-
Constructor Summary
ConstructorsModifierConstructorDescriptionIndex()Index(String key, Sort.Direction direction) <T,P> Index(TypedPropertyPath<T, P> property, Sort.Direction direction) -
Method Summary
Modifier and TypeMethodDescriptionDeprecated, for removal: This API element is subject to removal in a future version.since 5.0 for removal without replacement.expire(long value) Specifies TTL in seconds.Specifies TTL with givenTimeUnit.Specifies the TTL.org.bson.DocumentGet theDocumentcontaining properties covered by the index.org.bson.DocumentGet the index properties such as unique,...hidden()Hidden indexes are not visible to the query planner and cannot be used to support a query.on(String key, Sort.Direction direction) <T,P> Index on(TypedPropertyPath<T, P> property, Sort.Direction direction) Append thepathto the target property to the index definition.partial(@Nullable IndexFilter filter) Only index the documents in a collection that meet a specifiedfilter expression.sparse()Skip over any document that is missing the indexed field.toString()unique()Reject all documents that contain a duplicate value for the indexed field.
-
Constructor Details
-
Index
public Index() -
Index
-
Index
- Type Parameters:
T- Property owing root typeP- Target property reachable via path.- Parameters:
property- must not be null.direction- index order- Since:
- 5.1
-
-
Method Details
-
on
-
on
@Contract("_, _ -> this") public <T,P> Index on(TypedPropertyPath<T, P> property, Sort.Direction direction) Append thepathto the target property to the index definition.- Type Parameters:
T- Property owing root typeP- Target property reachable via path.- Parameters:
property- the property to include.direction- the direction to order values within the index.- Returns:
- this.
- Since:
- 5.1
-
named
-
unique
-
sparse
-
background
Deprecated, for removal: This API element is subject to removal in a future version.since 5.0 for removal without replacement.Build the index in background (non blocking).NOTE: Since MongoDB 4.2 the background flag is ignored by the server if set.
- Returns:
- this.
- Since:
- 1.5
-
expire
-
expire
Specifies the TTL.- Parameters:
timeout- must not be null.- Returns:
- this.
- Throws:
IllegalArgumentException- if given timeout is null.- Since:
- 2.2
-
expire
-
partial
Only index the documents in a collection that meet a specifiedfilter expression.- Parameters:
filter- can be null.- Returns:
- this.
- Since:
- 1.10
- See Also:
-
collation
-
getIndexKeys
public org.bson.Document getIndexKeys()Description copied from interface:IndexDefinitionGet theDocumentcontaining properties covered by the index.- Specified by:
getIndexKeysin interfaceIndexDefinition- Returns:
- never null.
-
getIndexOptions
public org.bson.Document getIndexOptions()Description copied from interface:IndexDefinitionGet the index properties such as unique,...- Specified by:
getIndexOptionsin interfaceIndexDefinition- Returns:
- never null.
-
toString
-