On 5月9日, 下午11时24分, Spencer T Brody <
spen...@10gen.com> wrote:
> Updates that don't include the shard key must be multi-updates. Since the
> update will be broadcast to all shards, the mongos has no way to ensure
> that only one document is updated. All updates are by default single
> updates, you must specify if you want them to be multi-updates. In the
> shell you can do this by setting the fourth parameter to the update
> function to true.
> Seehttp://
www.mongodb.org/display/DOCS/Updating#Updating-update%28%29for
> more information about doing a multi-update.
>
> I updated the documentation you linked to to make this behavior clearer.
>
>
>
>
>
>
>
> On Wednesday, May 9, 2012 12:26:22 AM UTC-4, Lei Chen wrote:
>
> > I have a collection samples sharded with key {a: 1, b: 1} and when I
> > do the operations below. I get an error:
> > mongos> db.samples.find({_id: ObjectId('4fa9d834da02534728000586')})
> > ...
> > mongos> db.samples.update({_id: ObjectId('4fa9d834da02534728000586')},
> > {$set: {deleted: 'true'}})
> > right object doesn't have full shard key
> > ...
> > And below operation is Ok
> > mongos> db.samples.update({_id: ObjectId('4fa9d834da02534728000586'),
> > a: 23, b: 99}, {$set: {deleted: 'true'}})
>
> > I notice that in