[CDRIVER-2096] Flexible index-creation Created: 23/Mar/17 Updated: 12/Sep/17 Resolved: 10/Aug/17 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | libmongoc |
| Affects Version/s: | None |
| Fix Version/s: | 1.8.0 |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | David Golden | Assignee: | A. Jesse Jiryu Davis |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
mongoc_collection_create_index_with_opts takes a mongoc_index_opt_t parameter. This has the unfortunately consequence that it must be updated as the server changes adds or deprecates index options. It also makes it harder for wrapper drivers to do anything other than implement a similar API. We'd like a API to just provide a bson_t* for index options and pass it through to the server and make construction of a correct index options document a user responsibility. |
| Comments |
| Comment by Ramon Fernandez Marina [ 12/Sep/17 ] | ||||||||||||||||||
|
Author: {'username': u'ajdavis', 'name': u'A. Jesse Jiryu Davis', 'email': u'jesse@mongodb.com'}Message:deprecate createIndexes helpers
| ||||||||||||||||||
| Comment by Githook User [ 11/Aug/17 ] | ||||||||||||||||||
|
Author: {'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis', 'email': 'jesse@mongodb.com'}Message: add createIndexes guide
| ||||||||||||||||||
| Comment by Githook User [ 11/Aug/17 ] | ||||||||||||||||||
|
Author: {'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis', 'email': 'jesse@mongodb.com'}Message: add createIndexes example
| ||||||||||||||||||
| Comment by Bernie Hackett [ 24/Mar/17 ] | ||||||||||||||||||
|
Oh, I thought it was introduced in 3.0, but I'm probably confusing it with listIndexes. | ||||||||||||||||||
| Comment by A. Jesse Jiryu Davis [ 24/Mar/17 ] | ||||||||||||||||||
|
Definitely requires dropping support for 2.4. But "createIndexes" was introduced in 2.6, so we'd be ok?: https://docs.mongodb.com/manual/reference/command/createIndexes/ | ||||||||||||||||||
| Comment by Bernie Hackett [ 24/Mar/17 ] | ||||||||||||||||||
|
Dropping the existing helpers requires dropping support for MongoDB 2.4 and 2.6. | ||||||||||||||||||
| Comment by A. Jesse Jiryu Davis [ 24/Mar/17 ] | ||||||||||||||||||
|
Here's the current APIs:
The "opts" version was created to allow writeConcern and collation: opts are appended to the createIndexes command, not to the index spec itself. So if MongoDB introduces a new index option "foo", there's no way to send a command like this to MongoDB with mongoc_collection_create_index_with_opts:
One approach is a third index function like David proposes. Another approach is to document how users can run "createIndexes" themselves via mongoc_collection_write_command_with_opts, and deprecate the existing family of index-creation functions and types. Users only need help with two things that mongoc_collection_write_command_with_opts doesn't provide: they need help generating the index name from its keys, and creating indexes on MongoDB 2.4. We can expose a new function that helps with the former and our commitment to the latter is ending imminently. | ||||||||||||||||||
| Comment by David Golden [ 24/Mar/17 ] | ||||||||||||||||||
|
Hypothetical API (with terrible name):
Conceptually, that might create the index model command like this:
Instead of like this. |