Ubuntu Manpages

WARNING:

Deprecated since version 1.8.0: This structure is deprecated and should not be used in new code. See Manage Collection Indexes.



This structure contains the options that may be used for tuning a specific index.

See the createIndexes documentations in the MongoDB manual for descriptions of individual options.

NOTE:

dropDups is deprecated as of MongoDB version 3.0.0. This option is silently ignored by the server and unique index builds using this option will fail if a duplicate value is detected.


{
   bson_t keys;
   bson_error_t error;
   mongoc_index_opt_t opt;
   mongoc_index_opt_geo_t geo_opt;
   mongoc_index_opt_init (&opt);
   mongoc_index_opt_geo_init (&geo_opt);
   bson_init (&keys);
   BSON_APPEND_UTF8 (&keys, "location", "2d");
   geo_opt.twod_location_min = -123;
   geo_opt.twod_location_max = +123;
   geo_opt.twod_bits_precision = 30;
   opt.geo_options = &geo_opt;
   collection = mongoc_client_get_collection (client, "test", "geo_test");
   if (mongoc_collection_create_index (collection, &keys, &opt, &error)) {
      /* Successfully created the geo index */
   }
   bson_destroy (&keys);
   mongoc_collection_destroy (&collection);
}


SEE ALSO:

mongoc_index_opt_geo_t

mongoc_index_opt_wt_t



MongoDB, Inc

2017-present, MongoDB, Inc