Table of Contents

Class IndexOptionsBuilder<TDocument>

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

A builder for the options used when creating an index.

[Serializable]
[BsonSerializer(typeof(IndexOptionsBuilder<>.Serializer))]
public class IndexOptionsBuilder<TDocument> : BuilderBase, IConvertibleToBsonDocument, IMongoIndexOptions

Type Parameters

TDocument

The type of the document.

Inheritance
IndexOptionsBuilder<TDocument>
Implements
Inherited Members
Extension Methods

Constructors

IndexOptionsBuilder()

Initializes a new instance of the IndexOptionsBuilder class.

public IndexOptionsBuilder()

Methods

SetBackground(bool)

Sets whether to build the index in the background.

public IndexOptionsBuilder<TDocument> SetBackground(bool value)

Parameters

value bool

Whether to build the index in the background.

Returns

IndexOptionsBuilder<TDocument>

The builder (so method calls can be chained).

SetBits(int)

Sets the location precision bits.

public IndexOptionsBuilder<TDocument> SetBits(int value)

Parameters

value int

The value.

Returns

IndexOptionsBuilder<TDocument>

The builder (so method calls can be chained).

SetBucketSize(double)

Sets the bucket size for geospatial haystack indexes.

[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
public IndexOptionsBuilder<TDocument> SetBucketSize(double value)

Parameters

value double

The bucket size.

Returns

IndexOptionsBuilder<TDocument>

The builder (so method calls can be chained).

SetDropDups(bool)

Sets whether duplicates should be dropped.

public IndexOptionsBuilder<TDocument> SetDropDups(bool value)

Parameters

value bool

Whether duplicates should be dropped.

Returns

IndexOptionsBuilder<TDocument>

The builder (so method calls can be chained).

SetGeoSpatialRange(double, double)

Sets the geospatial range.

public IndexOptionsBuilder<TDocument> SetGeoSpatialRange(double min, double max)

Parameters

min double

The min value of the range.

max double

The max value of the range.

Returns

IndexOptionsBuilder<TDocument>

The builder (so method calls can be chained).

SetHidden(bool)

Sets whether the index is hidden.

public IndexOptionsBuilder<TDocument> SetHidden(bool value)

Parameters

value bool

Whether the index is hidden.

Returns

IndexOptionsBuilder<TDocument>

The builder (so method calls can be chained).

SetName(string)

Sets the name of the index.

public IndexOptionsBuilder<TDocument> SetName(string value)

Parameters

value string

The name of the index.

Returns

IndexOptionsBuilder<TDocument>

The builder (so method calls can be chained).

SetPartialFilterExpression(IMongoQuery)

Sets the partial filter expression.

public IndexOptionsBuilder<TDocument> SetPartialFilterExpression(IMongoQuery value)

Parameters

value IMongoQuery

The value.

Returns

IndexOptionsBuilder<TDocument>

The builder (so method calls can be chained).

SetSparse(bool)

Sets whether the index is a sparse index.

public IndexOptionsBuilder<TDocument> SetSparse(bool value)

Parameters

value bool

Whether the index is a sparse index.

Returns

IndexOptionsBuilder<TDocument>

The builder (so method calls can be chained).

SetStorageEngineOptions(BsonDocument)

Sets the storage engine options.

public IndexOptionsBuilder<TDocument> SetStorageEngineOptions(BsonDocument value)

Parameters

value BsonDocument

The value.

Returns

IndexOptionsBuilder<TDocument>

The builder (so method calls can be chained).

SetTextDefaultLanguage(string)

Sets the default language for the text index.

public IndexOptionsBuilder<TDocument> SetTextDefaultLanguage(string language)

Parameters

language string

The default language.

Returns

IndexOptionsBuilder<TDocument>

The builder (so method calls can be chained).

SetTextLanguageOverride(Expression<Func<TDocument, string>>)

Specifies a member expression for the field name containing the language for the text index.

public IndexOptionsBuilder<TDocument> SetTextLanguageOverride(Expression<Func<TDocument, string>> memberExpression)

Parameters

memberExpression Expression<Func<TDocument, string>>

The member expression indicating the language field name.

Returns

IndexOptionsBuilder<TDocument>

The builder (so method calls can be chained).

SetTimeToLive(TimeSpan)

Sets the time to live value.

public IndexOptionsBuilder<TDocument> SetTimeToLive(TimeSpan timeToLive)

Parameters

timeToLive TimeSpan

The time to live.

Returns

IndexOptionsBuilder<TDocument>

The builder (so method calls can be chained).

SetUnique(bool)

Sets whether the index enforces unique values.

public IndexOptionsBuilder<TDocument> SetUnique(bool value)

Parameters

value bool

Whether the index enforces unique values.

Returns

IndexOptionsBuilder<TDocument>

The builder (so method calls can be chained).

SetWeight<TMember>(Expression<Func<TDocument, TMember>>, int)

Sets the weight of a field for the text index.

public IndexOptionsBuilder<TDocument> SetWeight<TMember>(Expression<Func<TDocument, TMember>> memberExpression, int value)

Parameters

memberExpression Expression<Func<TDocument, TMember>>

The member expression.

value int

The value.

Returns

IndexOptionsBuilder<TDocument>

The builder (so method calls can be chained).

Type Parameters

TMember

The type of the member.

SetWildcardProjection<TMember>(Expression<Func<TDocument, TMember>>, bool)

Sets the wildcardProjection for the index.

public IndexOptionsBuilder<TDocument> SetWildcardProjection<TMember>(Expression<Func<TDocument, TMember>> memberExpression, bool included)

Parameters

memberExpression Expression<Func<TDocument, TMember>>

The member expression representing the wildcard projection field name.

included bool

The flag determines whether the field should be included or excluded from wildcard projecting.

Returns

IndexOptionsBuilder<TDocument>

The builder (so method calls can be chained).

Type Parameters

TMember

The type of the member.

ToBsonDocument()

Converts this object to a BsonDocument.

public override BsonDocument ToBsonDocument()

Returns

BsonDocument

A BsonDocument.