[DOCS-10093] Comment on: "manual/core/index-sparse.txt" Created: 07/Apr/17  Updated: 27/Oct/23  Resolved: 11/Apr/17

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Docs Collector User (Inactive) Assignee: Kay Kim (Inactive)
Resolution: Works as Designed Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Location: https://docs.mongodb.com/v2.4/core/index-sparse/#index-type-sparse
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
Screen Resolution: 1366 x 768


Participants:
Days since reply: 6 years, 44 weeks, 1 day ago

 Description   

For mongodb v2.6

The example at the end of this page seems wrong.

However, this index would not permit adding the following documents:

db.scores.insert(

{ "userid": "PWWfO8lFs1", "score": 82 }

)
db.scores.insert(

{ "userid": "XlSOX66gEy", "score": 90 }

)

It has different score values but it states that due to sparse index on score field these statements would not execute fine.



 Comments   
Comment by Kay Kim (Inactive) [ 11/Apr/17 ]

The example refers to the collection that has:

{ "_id" : ObjectId("523b6e32fb408eea0eec2647"), "userid" : "newbie" } { "_id" : ObjectId("523b6e61fb408eea0eec2648"), "userid" : "abby", "score" : 82 } { "_id" : ObjectId("523b6e6ffb408eea0eec2649"), "userid" : "nina", "score" : 90 }

As such, with the unique,sparse index, you cannot add new documents that contain the score 82 or 90:
db.scores.insert(

{ "userid": "AAAAAAA", "score": 82 }

)
db.scores.insert(

{ "userid": "BBBBBBB", "score": 90 }

)

Generated at Thu Feb 08 07:59:48 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.