MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
mongocxx::options::index Class Reference

#include <mongocxx/v_noabi/mongocxx/options/index.hpp>

Description

Used by MongoDB index creation operations.

See also

Classes

class  base_storage_options
 Base class representing the optional storage engine options for indexes. More...
class  wiredtiger_storage_options
 The optional WiredTiger storage engine options for indexes. More...

Public Member Functions

 index ()=default
 Default initialization.
 index (v1::indexes::options const &opts)
 Construct with the mongocxx::v1 equivalent.
bsoncxx::v_noabi::stdx::optional< bool > const & background () const
 The current background setting.
indexbackground (bool background)
 Whether or not to build the index in the background so that building the index does not block other database activities. The default is to build indexes in the foreground.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view > const & collation () const
 Retrieves the current collation for this index.
indexcollation (bsoncxx::v_noabi::document::view collation)
 Sets the collation for this index.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::string::view_or_value > const & default_language () const
 The current default_language setting.
indexdefault_language (bsoncxx::v_noabi::string::view_or_value default_language)
 For text indexes, the language that determines the list of stop words and the rules for the stemmer and tokenizer.
bsoncxx::v_noabi::stdx::optional< std::chrono::seconds > const & expire_after () const
 The current expire_after setting.
indexexpire_after (std::chrono::seconds seconds)
 Set a value, in seconds, as a TTL to control how long MongoDB retains documents in this collection.
bsoncxx::v_noabi::stdx::optional< double > const & haystack_bucket_size () const
 The current haystack_bucket_size setting.
indexhaystack_bucket_size (double haystack_bucket_size)
 For geoHaystack indexes, specify the number of units within which to group the location values; i.e. group in the same bucket those location values that are within the specified number of units to each other.
bsoncxx::v_noabi::stdx::optional< bool > const & hidden () const
 The current hidden setting.
indexhidden (bool hidden)
 Whether or not the index is hidden from the query planner. A hidden index is not evaluated as part of query plan selection.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::string::view_or_value > const & language_override () const
 The current name of the field that contains the override language for text indexes.
indexlanguage_override (bsoncxx::v_noabi::string::view_or_value language_override)
 For text indexes, the name of the field, in the collection’s documents, that contains the override language for the document.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::string::view_or_value > const & name () const
 The current name setting.
indexname (bsoncxx::v_noabi::string::view_or_value name)
 The name of the index.
 operator bsoncxx::v_noabi::document::view_or_value ()
 Conversion operator that provides a view of the options in document form.
 operator v1::indexes::options () const
 Convert to the mongocxx::v1 equivalent.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view > const & partial_filter_expression () const
 The current partial_filter_expression setting.
indexpartial_filter_expression (bsoncxx::v_noabi::document::view partial_filter_expression)
 Sets the document for the partial filter expression for partial indexes.
bsoncxx::v_noabi::stdx::optional< bool > const & sparse () const
 The current sparse setting.
indexsparse (bool sparse)
 Whether or not to create a sparse index. Sparse indexes only reference documents with the indexed fields.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view > const & storage_engine () const
 The current storage engine options.
indexstorage_engine (bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view > storage_engine)
 Specifies the storage engine options for the index.
indexstorage_options (std::unique_ptr< base_storage_options > storage_options)
 Specifies the storage engine options for the index.
indexstorage_options (std::unique_ptr< wiredtiger_storage_options > storage_options)
 Specifies the WiredTiger-specific storage engine options for the index.
bsoncxx::v_noabi::stdx::optional< std::uint8_t > const & twod_bits_precision () const
 The current precision of the stored geohash value of the location data.
indextwod_bits_precision (std::uint8_t twod_bits_precision)
 For 2d indexes, the precision of the stored geohash value of the location data.
bsoncxx::v_noabi::stdx::optional< double > const & twod_location_max () const
 The current upper inclusive boundary for the longitude and latitude values.
indextwod_location_max (double twod_location_max)
 For 2d indexes, the upper inclusive boundary for the longitude and latitude values.
bsoncxx::v_noabi::stdx::optional< double > const & twod_location_min () const
 The current lower inclusive boundary for the longitude and latitude values.
indextwod_location_min (double twod_location_min)
 For 2d indexes, the lower inclusive boundary for the longitude and latitude values.
bsoncxx::v_noabi::stdx::optional< std::uint8_t > const & twod_sphere_version () const
 The current twod_sphere_version setting.
indextwod_sphere_version (std::uint8_t twod_sphere_version)
 For 2dsphere indexes, the 2dsphere index version number. Version can be either 1 or 2.
bsoncxx::v_noabi::stdx::optional< bool > const & unique () const
 The current unique setting.
indexunique (bool unique)
 Whether or not to create a unique index so that the collection will not accept insertion of documents where the index key or keys match an existing value in the index.
bsoncxx::v_noabi::stdx::optional< std::int32_t > const & version () const
 The current index version.
indexversion (std::int32_t v)
 Sets the index version.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view > const & weights () const
 The current weights setting.
indexweights (bsoncxx::v_noabi::document::view weights)
 For text indexes, sets the weight document. The weight document contains field and weight pairs.

Constructor & Destructor Documentation

◆ index() [1/2]

Default initialization.

◆ index() [2/2]

Construct with the mongocxx::v1 equivalent.

Warning
The fields owned by opts MUST outlive the views in this object.

Member Function Documentation

◆ background() [1/2]

The current background setting.

Returns
The current background.

◆ background() [2/2]

Whether or not to build the index in the background so that building the index does not block other database activities. The default is to build indexes in the foreground.

Parameters
backgroundWhether or not to build the index in the background.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.
See also

◆ collation() [1/2]

Retrieves the current collation for this index.

Returns
The current collation.
See also

◆ collation() [2/2]

Sets the collation for this index.

Parameters
collationThe new collation.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.
See also

◆ default_language() [1/2]

The current default_language setting.

Returns
The current default_language.

◆ default_language() [2/2]

For text indexes, the language that determines the list of stop words and the rules for the stemmer and tokenizer.

Parameters
default_languageThe default language used when creating text indexes.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.

◆ expire_after() [1/2]

The current expire_after setting.

Returns
The current expire_after value.

◆ expire_after() [2/2]

index & mongocxx::v_noabi::options::index::expire_after ( std::chrono::seconds seconds)
inline

Set a value, in seconds, as a TTL to control how long MongoDB retains documents in this collection.

Parameters
secondsThe amount of time, in seconds, to retain documents.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.
See also

◆ haystack_bucket_size() [1/2]

The current haystack_bucket_size setting.

Returns
The current haystack_bucket_size.
Deprecated
This method is deprecated.

◆ haystack_bucket_size() [2/2]

index & mongocxx::v_noabi::options::index::haystack_bucket_size ( double haystack_bucket_size)
inline

For geoHaystack indexes, specify the number of units within which to group the location values; i.e. group in the same bucket those location values that are within the specified number of units to each other.

See also
Parameters
haystack_bucket_sizeThe geoHaystack bucket size.
Deprecated
This option is deprecated.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.

◆ hidden() [1/2]

The current hidden setting.

Returns
The current hidden.

◆ hidden() [2/2]

Whether or not the index is hidden from the query planner. A hidden index is not evaluated as part of query plan selection.

Parameters
hiddenWhether or not to create a hidden index.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.
See also

◆ language_override() [1/2]

The current name of the field that contains the override language for text indexes.

Returns
The name of the field that contains the override language for text indexes.

◆ language_override() [2/2]

For text indexes, the name of the field, in the collection’s documents, that contains the override language for the document.

Parameters
language_overrideThe name of the field that contains the override language for text indexes.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.

◆ name() [1/2]

The current name setting.

Returns
The current name.

◆ name() [2/2]

The name of the index.

Parameters
nameThe name of the index.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.

◆ operator bsoncxx::v_noabi::document::view_or_value()

mongocxx::v_noabi::options::index::operator bsoncxx::v_noabi::document::view_or_value ( )

Conversion operator that provides a view of the options in document form.

Exceptions
mongocxx::v_noabi::logic_errorif an invalid expireAfterSeconds field is provided.
Returns
A view of the current builder contents.

◆ operator v1::indexes::options()

mongocxx::v_noabi::options::index::operator v1::indexes::options ( ) const
inlineexplicit

Convert to the mongocxx::v1 equivalent.

Note
The storage_options and haystack_bucket_size fields are ignored.

◆ partial_filter_expression() [1/2]

The current partial_filter_expression setting.

Returns
The current partial_filter_expression.

◆ partial_filter_expression() [2/2]

Sets the document for the partial filter expression for partial indexes.

Parameters
partial_filter_expressionThe partial filter expression document.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.

◆ sparse() [1/2]

The current sparse setting.

Returns
The current sparse setting.

◆ sparse() [2/2]

Whether or not to create a sparse index. Sparse indexes only reference documents with the indexed fields.

Parameters
sparseWhether or not to create a sparse index.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.
See also

◆ storage_engine() [1/2]

◆ storage_engine() [2/2]

Specifies the storage engine options for the index.

Important
This option overrides storage_options when set.

The document must have the form { <storage-engine-name>: <options> }, e.g.:

{ "wiredTiger": {"configString": "block_compressor=zlib"} }
Parameters
storage_engineThe storage engine options for the index.
See also

◆ storage_options() [1/2]

index & mongocxx::v_noabi::options::index::storage_options ( std::unique_ptr< base_storage_options > storage_options)
inline

Specifies the storage engine options for the index.

Important
This option is overridden by storage_engine when set.
Parameters
storage_optionsThe storage engine options for the index.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.
Deprecated
Use mongocxx::v_noabi::options::index::storage_engine instead.

◆ storage_options() [2/2]

Specifies the WiredTiger-specific storage engine options for the index.

Important
This option is overridden by storage_engine when set.
Parameters
storage_optionsThe storage engine options for the index.
Deprecated
Use mongocxx::v_noabi::options::index::storage_engine instead.

◆ twod_bits_precision() [1/2]

The current precision of the stored geohash value of the location data.

Returns
The precision of the stored geohash value of the location data.

◆ twod_bits_precision() [2/2]

index & mongocxx::v_noabi::options::index::twod_bits_precision ( std::uint8_t twod_bits_precision)
inline

For 2d indexes, the precision of the stored geohash value of the location data.

Parameters
twod_bits_precisionThe precision of the stored geohash value.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.

◆ twod_location_max() [1/2]

The current upper inclusive boundary for the longitude and latitude values.

Returns
The upper inclusive boundary for the longitude and latitude values.

◆ twod_location_max() [2/2]

index & mongocxx::v_noabi::options::index::twod_location_max ( double twod_location_max)
inline

For 2d indexes, the upper inclusive boundary for the longitude and latitude values.

Parameters
twod_location_maxThe upper inclusive boundary.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.

◆ twod_location_min() [1/2]

The current lower inclusive boundary for the longitude and latitude values.

Returns
The lower inclusive boundary for the longitude and latitude values.

◆ twod_location_min() [2/2]

index & mongocxx::v_noabi::options::index::twod_location_min ( double twod_location_min)
inline

For 2d indexes, the lower inclusive boundary for the longitude and latitude values.

Parameters
twod_location_minThe lower inclusive boundary.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.

◆ twod_sphere_version() [1/2]

The current twod_sphere_version setting.

Returns
The current twod_sphere_version.

◆ twod_sphere_version() [2/2]

index & mongocxx::v_noabi::options::index::twod_sphere_version ( std::uint8_t twod_sphere_version)
inline

For 2dsphere indexes, the 2dsphere index version number. Version can be either 1 or 2.

Parameters
twod_sphere_versionThe 2dsphere index version number.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.

◆ unique() [1/2]

The current unique setting.

Returns
The current unique.

◆ unique() [2/2]

Whether or not to create a unique index so that the collection will not accept insertion of documents where the index key or keys match an existing value in the index.

Parameters
uniqueWhether or not to create a unique index.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.
See also

◆ version() [1/2]

The current index version.

Returns
The current index version.

◆ version() [2/2]

Sets the index version.

Parameters
vThe index version.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.

◆ weights() [1/2]

The current weights setting.

Returns
The current weights.

◆ weights() [2/2]

For text indexes, sets the weight document. The weight document contains field and weight pairs.

Parameters
weightsThe weight document for text indexes.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.

The documentation for this class was generated from the following file:
  • mongocxx/v_noabi/mongocxx/options/index.hpp