createIndex

fun <T : Any> MongoCollection<T>.createIndex(keys: String, indexOptions: IndexOptions = IndexOptions()): String

Create an index with the given keys and options.

Return

the index name

Parameters

keys

an object describing the index key(s), which may not be null.

indexOptions

the options for the index


fun <T : Any> MongoCollection<T>.createIndex(clientSession: ClientSession, keys: String, indexOptions: IndexOptions = IndexOptions()): String

Create an index with the given keys and options.

Return

the index name

Parameters

clientSession

the client session with which to associate this operation

keys

an object describing the index key(s), which may not be null.

indexOptions

the options for the index