Closed alcaeus closed 6 years ago
It looks like we'll get this functionality in a future version of libmongoc (CDRIVER-1110). Our tracking ticket is: PHPC-578.
I noticed this has been fixed in libmongoc 1.7.0 - any chance we'll see it in one of the next driver releases?
Doctrine MongoDB ODM relies on this feature when enabling sharding. The code could be refactored to add the shard key as regular index if it doesn't exist yet, but I thought it was better to rely on the server to let us know of a recommended index for the shard key.
I'll discuss this with @derickr tomorrow during our ticket triage. :+1:
Some commands return additional information when encountering an error. In this specific case, the
shardCollection
command contains a list of indexes and a proposed key in its result if the shard key is not already present as an index:However, when running this command through the driver, the resulting
MongoDB\Driver\Exception\RuntimeException
does not contain theproposedKey
andcurIndexes
fields. This makes it impossible to use the command result to get the proper index one should create for the shard key.