MongoDB C++ Driver
legacy-1.1.2
|
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... | |
IndexSpec & | addKey (const StringData &field, IndexType type=kIndexTypeAscending) |
Add a new component, by default ascending, field to index. More... | |
IndexSpec & | addKey (const BSONElement &fieldAndType) |
Add a component to this index. More... | |
IndexSpec & | addKeys (const BSONObj &keys) |
Add all keys from the provided object to the index descriptor. More... | |
IndexSpec & | background (bool value=true) |
Controls whether this index should be built in the foreground or background. More... | |
IndexSpec & | unique (bool value=true) |
Set whether or not this index should enforce uniqueness. More... | |
IndexSpec & | name (const StringData &name) |
Set the name for this index. More... | |
IndexSpec & | dropDuplicates (bool value=true) |
Sets whether duplicates detected while indexing should be dropped. More... | |
IndexSpec & | dropDuplicatesDeprecated (bool value=true) |
Same as above, but doesn't emit a compiler warning on use. | |
IndexSpec & | sparse (bool value=true) |
Sets whether or not this index should be sparse. More... | |
IndexSpec & | expireAfterSeconds (int value) |
Enables time-to-live semantics for this index with the specified lifetime in seconds. More... | |
IndexSpec & | version (int value) |
Explicitly request an index of the given version. More... | |
IndexSpec & | partialFilterExpression (const BSONObj &value) |
Sets the 'partialFilterExpression' document for a partial index. More... | |
IndexSpec & | textWeights (const BSONObj &value) |
Sets the 'weights' document for a text index. More... | |
IndexSpec & | textDefaultLanguage (const StringData &value) |
Sets the default language for a text index. More... | |
IndexSpec & | textLanguageOverride (const StringData &value) |
Sets the name of the field containing the language override in a text index. More... | |
IndexSpec & | textIndexVersion (int value) |
Sets the version of the text index to use. More... | |
IndexSpec & | geo2DSphereIndexVersion (int value) |
Sets the version of the 2D sphere index to use. More... | |
IndexSpec & | geo2DBits (int value) |
Sets the number of bits of precision for geohash. More... | |
IndexSpec & | geo2DMin (double value) |
Sets the minimum value for keys in a geo2d index. More... | |
IndexSpec & | geo2DMax (double value) |
Sets the maximum value for keys in a geo2d index. More... | |
IndexSpec & | geoHaystackBucketSize (double value) |
Sets the bucket size for haystack indexes. More... | |
IndexSpec & | addOption (const BSONElement &option) |
Adds another option verbatim. More... | |
IndexSpec & | addOptions (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... | |
typedef std::vector<std::pair<std::string, IndexType> > mongo::IndexSpec::KeyVector |
Add all components in the provided key vector to the index descriptor.
mongo::IndexSpec::IndexSpec | ( | ) |
Create a new IndexSpec.
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.
Add all keys from the provided object to the index descriptor.
IndexSpec& mongo::IndexSpec::addOption | ( | const BSONElement & | option | ) |
Adds another option verbatim.
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.
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.
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.