Table of Contents

Class IndexKeys

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

A builder for specifying the keys for an index.

public static class IndexKeys
Inheritance
IndexKeys
Inherited Members

Methods

Ascending(params string[])

Sets one or more key names to index in ascending order.

public static IndexKeysBuilder Ascending(params string[] names)

Parameters

names string[]

One or more key names.

Returns

IndexKeysBuilder

The builder (so method calls can be chained).

Descending(params string[])

Sets one or more key names to index in descending order.

public static IndexKeysBuilder Descending(params string[] names)

Parameters

names string[]

One or more key names.

Returns

IndexKeysBuilder

The builder (so method calls can be chained).

GeoSpatial(string)

Sets the key name to create a geospatial index on.

public static IndexKeysBuilder GeoSpatial(string name)

Parameters

name string

The key name.

Returns

IndexKeysBuilder

The builder (so method calls can be chained).

GeoSpatialHaystack(string)

Sets the key name to create a geospatial haystack index on.

[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
public static IndexKeysBuilder GeoSpatialHaystack(string name)

Parameters

name string

The key name.

Returns

IndexKeysBuilder

The builder (so method calls can be chained).

GeoSpatialHaystack(string, string)

Sets the key name and additional field name to create a geospatial haystack index on.

[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
public static IndexKeysBuilder GeoSpatialHaystack(string name, string additionalName)

Parameters

name string

The key name.

additionalName string

The name of an additional field to index.

Returns

IndexKeysBuilder

The builder (so method calls can be chained).

GeoSpatialSpherical(string)

Sets the key name to create a spherical geospatial index on.

public static IndexKeysBuilder GeoSpatialSpherical(string name)

Parameters

name string

The key name.

Returns

IndexKeysBuilder

The builder (so method calls can be chained).

Hashed(string)

Sets the key name to create a hashed index on.

public static IndexKeysBuilder Hashed(string name)

Parameters

name string

The key name.

Returns

IndexKeysBuilder

The builder (so method calls can be chained).

Text(params string[])

Sets one or more key names to include in the text index.

public static IndexKeysBuilder Text(params string[] names)

Parameters

names string[]

List of key names to include in the text index.

Returns

IndexKeysBuilder

The builder (so method calls can be chained).

TextAll()

Create a text index that indexes all text fields of a document.

public static IndexKeysBuilder TextAll()

Returns

IndexKeysBuilder

The builder (so method calls can be chained).

Wildcard(string)

Sets a wildcard key to the index. The method doesn't expect to specify a wildcard key explicitly.

public static IndexKeysBuilder Wildcard(string name = null)

Parameters

name string

The wildcard key name. If the wildcard name is empty, the generated key will be All field paths, otherwise A single field path.

Returns

IndexKeysBuilder

The builder (so method calls can be chained).