Table of Contents

Method EnsureIndex

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.Legacy.dll

EnsureIndex(IMongoIndexKeys, IMongoIndexOptions)

Ensures that the desired index exists and creates it if it does not.

[Obsolete("Use CreateIndex instead.")]
public virtual void EnsureIndex(IMongoIndexKeys keys, IMongoIndexOptions options)

Parameters

keys IMongoIndexKeys

The indexed fields (usually an IndexKeysDocument or constructed using the IndexKeys builder).

options IMongoIndexOptions

The index options(usually an IndexOptionsDocument or created using the IndexOption builder).

EnsureIndex(IMongoIndexKeys)

Ensures that the desired index exists and creates it if it does not.

[Obsolete("Use CreateIndex instead.")]
public virtual void EnsureIndex(IMongoIndexKeys keys)

Parameters

keys IMongoIndexKeys

The indexed fields (usually an IndexKeysDocument or constructed using the IndexKeys builder).

EnsureIndex(params string[])

Ensures that the desired index exists and creates it if it does not.

[Obsolete("Use CreateIndex instead.")]
public virtual void EnsureIndex(params string[] keyNames)

Parameters

keyNames string[]

The names of the indexed fields.