MongoDB C++ Driver  mongocxx-3.4.0
Classes | Public Member Functions | List of all members
mongocxx::options::index Class Reference

Class representing the optional arguments to a MongoDB create index operation. More...

#include <index.hpp>

Classes

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

Public Member Functions

indexbackground (bool background)
 Whether or not to build the index in the background so that building the index does not block other database activities. More...
 
const stdx::optional< bool > & background () const
 The current background setting. More...
 
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. More...
 
const stdx::optional< bool > & unique () const
 The current unique setting. More...
 
indexname (bsoncxx::string::view_or_value name)
 The name of the index. More...
 
const stdx::optional< bsoncxx::string::view_or_value > & name () const
 The current name setting. More...
 
indexcollation (bsoncxx::document::view collation)
 Sets the collation for this index. More...
 
const stdx::optional< bsoncxx::document::view > & collation () const
 Retrieves the current collation for this index. More...
 
indexsparse (bool sparse)
 Whether or not to create a sparse index. More...
 
const stdx::optional< bool > & sparse () const
 The current sparse setting. More...
 
indexstorage_options (std::unique_ptr< base_storage_options > storage_options)
 Optionally used only in MongoDB 3.0.0 and higher. More...
 
indexstorage_options (std::unique_ptr< wiredtiger_storage_options > storage_options)
 Optionally used only in MongoDB 3.0.0 and higher. More...
 
indexexpire_after (std::chrono::seconds seconds)
 Set a value, in seconds, as a TTL to control how long MongoDB retains documents in this collection. More...
 
const stdx::optional< std::chrono::seconds > & expire_after () const
 The current expire_after setting. More...
 
indexversion (std::int32_t v)
 Sets the index version. More...
 
const stdx::optional< std::int32_t > & version () const
 The current index version. More...
 
indexweights (bsoncxx::document::view weights)
 For text indexes, sets the weight document. More...
 
const stdx::optional< bsoncxx::document::view > & weights () const
 The current weights setting. More...
 
indexdefault_language (bsoncxx::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. More...
 
const stdx::optional< bsoncxx::string::view_or_value > & default_language () const
 The current default_language setting. More...
 
indexlanguage_override (bsoncxx::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. More...
 
const stdx::optional< bsoncxx::string::view_or_value > & language_override () const
 The current name of the field that contains the override language for text indexes. More...
 
indexpartial_filter_expression (bsoncxx::document::view partial_filter_expression)
 Sets the document for the partial filter expression for partial indexes. More...
 
const stdx::optional< bsoncxx::document::view > & partial_filter_expression () const
 The current partial_filter_expression setting. More...
 
indextwod_sphere_version (std::uint8_t twod_sphere_version)
 For 2dsphere indexes, the 2dsphere index version number. More...
 
const stdx::optional< std::uint8_t > & twod_sphere_version () const
 The current twod_sphere_version setting. More...
 
indextwod_bits_precision (std::uint8_t twod_bits_precision)
 For 2d indexes, the precision of the stored geohash value of the location data. More...
 
const stdx::optional< std::uint8_t > & twod_bits_precision () const
 The current precision of the stored geohash value of the location data. More...
 
indextwod_location_min (double twod_location_min)
 For 2d indexes, the lower inclusive boundary for the longitude and latitude values. More...
 
const stdx::optional< double > & twod_location_min () const
 The current lower inclusive boundary for the longitude and latitude values. More...
 
indextwod_location_max (double twod_location_max)
 For 2d indexes, the upper inclusive boundary for the longitude and latitude values. More...
 
const stdx::optional< double > & twod_location_max () const
 The current upper inclusive boundary for the longitude and latitude values. More...
 
indexhaystack_bucket_size (double haystack_bucket_size)
 For geoHaystack indexes, specify the number of units within which to group the location values; i.e. More...
 
const stdx::optional< double > & haystack_bucket_size () const
 The current haystack_bucket_size setting. More...
 
 operator bsoncxx::document::view_or_value ()
 Conversion operator that provides a view of the options in document form. More...
 

Detailed Description

Class representing the optional arguments to a MongoDB create index operation.

See also
https://docs.mongodb.com/master/reference/command/createIndexes

Member Function Documentation

◆ background() [1/2]

index& mongocxx::options::index::background ( 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

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
https://docs.mongodb.com/master/tutorial/build-indexes-in-the-background/

◆ background() [2/2]

const stdx::optional<bool>& mongocxx::options::index::background ( ) const

The current background setting.

Returns
The current background.

◆ collation() [1/2]

index& mongocxx::options::index::collation ( bsoncxx::document::view  collation)

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
https://docs.mongodb.com/master/reference/collation/

◆ collation() [2/2]

const stdx::optional<bsoncxx::document::view>& mongocxx::options::index::collation ( ) const

Retrieves the current collation for this index.

Returns
The current collation.
See also
https://docs.mongodb.com/master/reference/collation/

◆ default_language() [1/2]

index& mongocxx::options::index::default_language ( bsoncxx::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.

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.

◆ default_language() [2/2]

const stdx::optional<bsoncxx::string::view_or_value>& mongocxx::options::index::default_language ( ) const

The current default_language setting.

Returns
The current default_language.

◆ expire_after() [1/2]

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

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
https://docs.mongodb.com/master/core/index-ttl/

◆ expire_after() [2/2]

const stdx::optional<std::chrono::seconds>& mongocxx::options::index::expire_after ( ) const

The current expire_after setting.

Returns
The current expire_after value.

◆ haystack_bucket_size() [1/2]

index& mongocxx::options::index::haystack_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.

See also
https://docs.mongodb.com/master/core/geohaystack/
Parameters
haystack_bucket_sizeThe geoHaystack bucket size.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.

◆ haystack_bucket_size() [2/2]

const stdx::optional<double>& mongocxx::options::index::haystack_bucket_size ( ) const

The current haystack_bucket_size setting.

Returns
The current haystack_bucket_size.

◆ language_override() [1/2]

index& mongocxx::options::index::language_override ( bsoncxx::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.

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.

◆ language_override() [2/2]

const stdx::optional<bsoncxx::string::view_or_value>& mongocxx::options::index::language_override ( ) const

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.

◆ name() [1/2]

index& mongocxx::options::index::name ( bsoncxx::string::view_or_value  name)

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.

◆ name() [2/2]

const stdx::optional<bsoncxx::string::view_or_value>& mongocxx::options::index::name ( ) const

The current name setting.

Returns
The current name.

◆ operator bsoncxx::document::view_or_value()

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

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

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

◆ partial_filter_expression() [1/2]

index& mongocxx::options::index::partial_filter_expression ( bsoncxx::document::view  partial_filter_expression)

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.

◆ partial_filter_expression() [2/2]

const stdx::optional<bsoncxx::document::view>& mongocxx::options::index::partial_filter_expression ( ) const

The current partial_filter_expression setting.

Returns
The current partial_filter_expression.

◆ sparse() [1/2]

index& mongocxx::options::index::sparse ( bool  sparse)

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
https://docs.mongodb.com/master/core/index-sparse/

◆ sparse() [2/2]

const stdx::optional<bool>& mongocxx::options::index::sparse ( ) const

The current sparse setting.

Returns
The current sparse setting.

◆ storage_options() [1/2]

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

Optionally used only in MongoDB 3.0.0 and higher.

Specifies the storage engine options for the index.

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.

◆ storage_options() [2/2]

index& mongocxx::options::index::storage_options ( std::unique_ptr< wiredtiger_storage_options storage_options)

Optionally used only in MongoDB 3.0.0 and higher.

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

Parameters
storage_optionsThe storage engine options for the index.

◆ twod_bits_precision() [1/2]

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

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_bits_precision() [2/2]

const stdx::optional<std::uint8_t>& mongocxx::options::index::twod_bits_precision ( ) const

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_location_max() [1/2]

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

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_max() [2/2]

const stdx::optional<double>& mongocxx::options::index::twod_location_max ( ) const

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

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

◆ twod_location_min() [1/2]

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

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_location_min() [2/2]

const stdx::optional<double>& mongocxx::options::index::twod_location_min ( ) const

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

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

◆ twod_sphere_version() [1/2]

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

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.

◆ twod_sphere_version() [2/2]

const stdx::optional<std::uint8_t>& mongocxx::options::index::twod_sphere_version ( ) const

The current twod_sphere_version setting.

Returns
The current twod_sphere_version.

◆ unique() [1/2]

index& mongocxx::options::index::unique ( 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.

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
https://docs.mongodb.com/master/core/index-unique/

◆ unique() [2/2]

const stdx::optional<bool>& mongocxx::options::index::unique ( ) const

The current unique setting.

Returns
The current unique.

◆ version() [1/2]

index& mongocxx::options::index::version ( std::int32_t  v)

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.

◆ version() [2/2]

const stdx::optional<std::int32_t>& mongocxx::options::index::version ( ) const

The current index version.

Returns
The current index version.

◆ weights() [1/2]

index& mongocxx::options::index::weights ( bsoncxx::document::view  weights)

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.

◆ weights() [2/2]

const stdx::optional<bsoncxx::document::view>& mongocxx::options::index::weights ( ) const

The current weights setting.

Returns
The current weights.

The documentation for this class was generated from the following file: