[DOCS-2151] Comment on: "manual/core/index-sparse.txt" Created: 25/Oct/13 Updated: 03/Nov/17 Resolved: 25/Oct/13 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 01112017-cleanup |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Kay Agahd | Assignee: | Kay Kim (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | collector-298ba4e7 | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
v2.4.6 Linux 64 bit Location: http://docs.mongodb.org/manual/core/index-sparse/ |
||
| Participants: | |
| Days since reply: | 10 years, 16 weeks, 5 days ago |
| Description |
|
Your example of the unique sparse index is wrong. Why shouldn't one be able to insert the last two records? Unique index is on score and not on userid! , { sparse: true, unique: true } ) ) ) ) ) mongos> db.scores.insert( { "userid": "PWWfO8lFs1", "score": "82" } ) ) mongos> |
| Comments |
| Comment by Kay Kim (Inactive) [ 25/Oct/13 ] | |||||||||||||||||||||||||
|
Hey Agahd – made the changes (although not yet published). Once published, the pages should reflect the correct example. Regards, Kay Kim | |||||||||||||||||||||||||
| Comment by auto [ 25/Oct/13 ] | |||||||||||||||||||||||||
|
Author: {u'username': u'kay-kim', u'name': u'kay', u'email': u'kay.kim@10gen.com'}Message: | |||||||||||||||||||||||||
| Comment by auto [ 25/Oct/13 ] | |||||||||||||||||||||||||
|
Author: {u'username': u'kay-kim', u'name': u'kay', u'email': u'kay.kim@10gen.com'}Message: | |||||||||||||||||||||||||
| Comment by Kay Agahd [ 25/Oct/13 ] | |||||||||||||||||||||||||
|
Wow, how fast are you, great! | |||||||||||||||||||||||||
| Comment by Kay Kim (Inactive) [ 25/Oct/13 ] | |||||||||||||||||||||||||
|
Hi Agahd – | |||||||||||||||||||||||||
| Comment by Kay Agahd [ 25/Oct/13 ] | |||||||||||||||||||||||||
|
I'm sorry about the formatting. I didn't find a way to edit my initial post. Furthermore, I only saw right now that your example pretends to have already this two documents:
So I understand why you said that the index should not permit adding the last two documents:
However, this is false nonetheless because the type of score is different (String vs. Number). Steps to reproduce:
| |||||||||||||||||||||||||
| Comment by Kay Kim (Inactive) [ 25/Oct/13 ] | |||||||||||||||||||||||||
|
Hi Agahd - However, the example incorrectly has enclosed the scores 82 and 90 in quotes, so in essence, "82" would not equal 82 and "90" would not equal 90 and thus the index would still allow these inserts. Will correct the example db.scores.insert( { "userid": "PWWfO8lFs1", "score": "82" } ) ) Will update this so that the two inserts that would fail would be: db.scores.insert( { "userid": "PWWfO8lFs1", "score": 82 } ) ) Thanks again. Kay |