[DOCS-7813] Sparse Index with Unique Constraint property not working as given in docs) Created: 05/May/16 Updated: 03/Nov/17 Resolved: 18/May/16 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 01112017-cleanup |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | vishal arora | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | collector-298ba4e7 | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
we are using mactentossh for running mongo Location: https://docs.mongodb.org/manual/core/index-sparse/ |
||
| Participants: | |
| Days since reply: | 7 years, 39 weeks, 1 day ago |
| Description |
|
AS per given docs index with unique will insert a new document if i have the unique value same but as i found result is opposite that it is not allowing to insert E1100 duplicate error i am getting Reporter: vishal |
| Comments |
| Comment by Kay Kim (Inactive) [ 18/May/16 ] |
|
Hi – thanks for filing this ticket. On the page, we state that (bolded here just to better highlight)
So, a unique, sparse index will not allow for duplicate keys; however, if the documents are missing the key, then it will allow the insert. So, if unique, sparse index on field x exists, you can insert into some collection collA: { x: 1 } { y: 0 } { y: 0 } { y: 1 }but not { x: 1}again. If the x index were only unique and not sparse, you could insert into some other collection collB: { x: 1} { y: 0 } <-- the x value would be null. or { y: 1 }since these would both have an x value of null and conflict with the already inserted { y: 0 }document. Hope this helps. Regards, Kay |