MongoDB C++ Driver  legacy-1.1.2
Public Types | Public Member Functions | List of all members
mongo::IndexSpec Class Reference

Public Types

typedef std::vector< std::pair< std::string, IndexType > > KeyVector
 Add all components in the provided key vector to the index descriptor. More...
 

Public Member Functions

 IndexSpec ()
 Create a new IndexSpec. More...
 
IndexSpecaddKey (const StringData &field, IndexType type=kIndexTypeAscending)
 Add a new component, by default ascending, field to index. More...
 
IndexSpecaddKey (const BSONElement &fieldAndType)
 Add a component to this index. More...
 
IndexSpecaddKeys (const BSONObj &keys)
 Add all keys from the provided object to the index descriptor. More...
 
IndexSpecbackground (bool value=true)
 Controls whether this index should be built in the foreground or background. More...
 
IndexSpecunique (bool value=true)
 Set whether or not this index should enforce uniqueness. More...
 
IndexSpecname (const StringData &name)
 Set the name for this index. More...
 
IndexSpecdropDuplicates (bool value=true)
 Sets whether duplicates detected while indexing should be dropped. More...
 
IndexSpecdropDuplicatesDeprecated (bool value=true)
 Same as above, but doesn't emit a compiler warning on use.
 
IndexSpecsparse (bool value=true)
 Sets whether or not this index should be sparse. More...
 
IndexSpecexpireAfterSeconds (int value)
 Enables time-to-live semantics for this index with the specified lifetime in seconds. More...
 
IndexSpecversion (int value)
 Explicitly request an index of the given version. More...
 
IndexSpecpartialFilterExpression (const BSONObj &value)
 Sets the 'partialFilterExpression' document for a partial index. More...
 
IndexSpectextWeights (const BSONObj &value)
 Sets the 'weights' document for a text index. More...
 
IndexSpectextDefaultLanguage (const StringData &value)
 Sets the default language for a text index. More...
 
IndexSpectextLanguageOverride (const StringData &value)
 Sets the name of the field containing the language override in a text index. More...
 
IndexSpectextIndexVersion (int value)
 Sets the version of the text index to use. More...
 
IndexSpecgeo2DSphereIndexVersion (int value)
 Sets the version of the 2D sphere index to use. More...
 
IndexSpecgeo2DBits (int value)
 Sets the number of bits of precision for geohash. More...
 
IndexSpecgeo2DMin (double value)
 Sets the minimum value for keys in a geo2d index. More...
 
IndexSpecgeo2DMax (double value)
 Sets the maximum value for keys in a geo2d index. More...
 
IndexSpecgeoHaystackBucketSize (double value)
 Sets the bucket size for haystack indexes. More...
 
IndexSpecaddOption (const BSONElement &option)
 Adds another option verbatim. More...
 
IndexSpecaddOptions (const BSONObj &options)
 Adds the provided options verbatim. More...
 
std::string name () const
 Get a copy of the current name for this index. More...
 
BSONObj toBSON () const
 Return a BSONObj that captures the selected index keys and options. More...
 

Member Typedef Documentation

typedef std::vector<std::pair<std::string, IndexType> > mongo::IndexSpec::KeyVector

Add all components in the provided key vector to the index descriptor.

Constructor & Destructor Documentation

mongo::IndexSpec::IndexSpec ( )

Create a new IndexSpec.

Member Function Documentation

IndexSpec& mongo::IndexSpec::addKey ( const StringData field,
IndexType  type = kIndexTypeAscending 
)

Add a new component, by default ascending, field to index.

IndexSpec& mongo::IndexSpec::addKey ( const BSONElement fieldAndType)

Add a component to this index.

The field name of the element is used as the field name to index. The value of the element is the index type. This method exists to accomodate building future index types for which the enumeration value has not yet been extended.

IndexSpec& mongo::IndexSpec::addKeys ( const BSONObj keys)

Add all keys from the provided object to the index descriptor.

IndexSpec& mongo::IndexSpec::addOption ( const BSONElement option)

Adds another option verbatim.

IndexSpec& mongo::IndexSpec::addOptions ( const BSONObj options)

Adds the provided options verbatim.

IndexSpec& mongo::IndexSpec::background ( bool  value = true)

Controls whether this index should be built in the foreground or background.

By default indexes are built in the foreground.

IndexSpec& mongo::IndexSpec::dropDuplicates ( bool  value = true)

Sets whether duplicates detected while indexing should be dropped.

By default, duplicates are not dropped.

IndexSpec& mongo::IndexSpec::expireAfterSeconds ( int  value)

Enables time-to-live semantics for this index with the specified lifetime in seconds.

Note that the indexed field must be of type UTC datetime for this option to work correctly.

IndexSpec& mongo::IndexSpec::geo2DBits ( int  value)

Sets the number of bits of precision for geohash.

IndexSpec& mongo::IndexSpec::geo2DMax ( double  value)

Sets the maximum value for keys in a geo2d index.

IndexSpec& mongo::IndexSpec::geo2DMin ( double  value)

Sets the minimum value for keys in a geo2d index.

IndexSpec& mongo::IndexSpec::geo2DSphereIndexVersion ( int  value)

Sets the version of the 2D sphere index to use.

MongoDB 2.4 only supports version '1'. If not otherwise specified, MongoDB 2.6 defaults to version 2.

IndexSpec& mongo::IndexSpec::geoHaystackBucketSize ( double  value)

Sets the bucket size for haystack indexes.

IndexSpec& mongo::IndexSpec::name ( const StringData name)

Set the name for this index.

If not set, a name will be automatically generated.

std::string mongo::IndexSpec::name ( ) const

Get a copy of the current name for this index.

If a name was provided to the constructor, a copy of this name is returned. Otherwise, the current auto-generated name given the set of indexes will be returned. Note that this is a copy: subsequent changes to the indexed fields will not affect the value returned here, and you must call 'name' again to obtain the updated value.

IndexSpec& mongo::IndexSpec::partialFilterExpression ( const BSONObj value)

Sets the 'partialFilterExpression' document for a partial index.

IndexSpec& mongo::IndexSpec::sparse ( bool  value = true)

Sets whether or not this index should be sparse.

By default, indexes are not sparse.

IndexSpec& mongo::IndexSpec::textDefaultLanguage ( const StringData value)

Sets the default language for a text index.

IndexSpec& mongo::IndexSpec::textIndexVersion ( int  value)

Sets the version of the text index to use.

MongoDB 2.4 only supports version '1'. If not otherwise specified, MongoDB 2.6 defaults to version 2.

IndexSpec& mongo::IndexSpec::textLanguageOverride ( const StringData value)

Sets the name of the field containing the language override in a text index.

IndexSpec& mongo::IndexSpec::textWeights ( const BSONObj value)

Sets the 'weights' document for a text index.

BSONObj mongo::IndexSpec::toBSON ( ) const

Return a BSONObj that captures the selected index keys and options.

IndexSpec& mongo::IndexSpec::unique ( bool  value = true)

Set whether or not this index should enforce uniqueness.

By default, uniqueness is not enforced.

IndexSpec& mongo::IndexSpec::version ( int  value)

Explicitly request an index of the given version.

As of MongoDB 2.6, the only accepted values are 0 or 1. Versions 2.0 and later default to '1'. Do not set this option except in unusual circumstances.


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