Class DefaultIndexOperations
java.lang.Object
org.springframework.data.mongodb.core.DefaultIndexOperations
- All Implemented Interfaces:
IndexOperations
Default implementation of
IndexOperations
.- Author:
- Mark Pollack, Oliver Gierke, Komi Innocent, Christoph Strobl, Mark Paluch
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultIndexOperations
(MongoOperations mongoOperations, String collectionName, Class<?> type) Creates a newDefaultIndexOperations
.DefaultIndexOperations
(MongoDatabaseFactory mongoDbFactory, String collectionName, QueryMapper queryMapper) Deprecated.since 2.1.DefaultIndexOperations
(MongoDatabaseFactory mongoDbFactory, String collectionName, QueryMapper queryMapper, Class<?> type) Deprecated.since 2.1. -
Method Summary
Modifier and TypeMethodDescriptionvoid
alterIndex
(String name, IndexOptions options) Alters the index with given name.void
Drops all indices from this collection.void
Drops an index from this collection.ensureIndex
(IndexDefinition indexDefinition) Ensure that an index for the providedIndexDefinition
exists for the collection indicated by the entity class.<T> T
execute
(CollectionCallback<T> callback) Returns the index information on the collection.
-
Constructor Details
-
DefaultIndexOperations
@Deprecated public DefaultIndexOperations(MongoDatabaseFactory mongoDbFactory, String collectionName, QueryMapper queryMapper) Deprecated.since 2.1. Please useDefaultIndexOperations(MongoOperations, String, Class)
.Creates a newDefaultIndexOperations
.- Parameters:
mongoDbFactory
- must not be null.collectionName
- must not be null.queryMapper
- must not be null.
-
DefaultIndexOperations
@Deprecated public DefaultIndexOperations(MongoDatabaseFactory mongoDbFactory, String collectionName, QueryMapper queryMapper, @Nullable Class<?> type) Deprecated.since 2.1. Please useDefaultIndexOperations(MongoOperations, String, Class)
.Creates a newDefaultIndexOperations
.- Parameters:
mongoDbFactory
- must not be null.collectionName
- must not be null.queryMapper
- must not be null.type
- Type used for mapping potential partial index filter expression. Can be null.- Since:
- 1.10
-
DefaultIndexOperations
public DefaultIndexOperations(MongoOperations mongoOperations, String collectionName, @Nullable Class<?> type) Creates a newDefaultIndexOperations
.- Parameters:
mongoOperations
- must not be null.collectionName
- must not be null or empty.type
- can be null.- Since:
- 2.1
-
-
Method Details
-
ensureIndex
Description copied from interface:IndexOperations
Ensure that an index for the providedIndexDefinition
exists for the collection indicated by the entity class. If not it will be created.- Specified by:
ensureIndex
in interfaceIndexOperations
- Parameters:
indexDefinition
- must not be null.- Returns:
- the index name.
-
dropIndex
Description copied from interface:IndexOperations
Drops an index from this collection.- Specified by:
dropIndex
in interfaceIndexOperations
- Parameters:
name
- name of index to drop
-
alterIndex
Description copied from interface:IndexOperations
Alters the index with given name.- Specified by:
alterIndex
in interfaceIndexOperations
- Parameters:
name
- name of index to change.options
- index options.
-
dropAllIndexes
public void dropAllIndexes()Description copied from interface:IndexOperations
Drops all indices from this collection.- Specified by:
dropAllIndexes
in interfaceIndexOperations
-
getIndexInfo
Description copied from interface:IndexOperations
Returns the index information on the collection.- Specified by:
getIndexInfo
in interfaceIndexOperations
- Returns:
- index information on the collection
-
execute
-