[DOCS-7579] Comment on: "manual/core/index-sparse.txt" Created: 05/Apr/16 Updated: 03/Nov/17 Resolved: 05/Apr/16 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 01112017-cleanup |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Docs Collector User (Inactive) | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | collector-298ba4e7 | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Location: https://docs.mongodb.org/v2.4/core/index-sparse/#index-type-sparse |
||
| Participants: | |
| Days since reply: | 7 years, 45 weeks, 1 day ago |
| Description |
|
The final statement on this page appears to be wrong: ``` db.scores.insert( { "userid": "PWWfO8lFs1", "score": 82 } ) ) It would allow those documents because their score value is unique. I think you accidentally set the userid's to be similar to past inserted data rather than the scores. I tested this simply by entering the commands: ``` , { sparse: true, unique: true }) { "createdCollectionAutomatically" : true, "numIndexesBefore" : 1, "numIndexesAfter" : 2, "ok" : 1 }> db.scores.insert( { "userid": "PWWfO8lFs1", "score": 43 } ) ) ) ) ) ) ) ) ) ) |
| Comments |
| Comment by Allison Reinheimer Moore [ 05/Apr/16 ] | |||
|
In that example, we first say: "Consider a collection scores that contains the following documents:
and then add the unique index on the score field. When we then try to insert the two documents you reference, they'd match the existing documents in the collection. Sorry for the confusion! |