[SERVER-3981] Creating a compound sparse index should uassert Created: 30/Sep/11  Updated: 10/Dec/14  Resolved: 15/Aug/13

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Kristina Chodorow (Inactive) Assignee: Randolph Tan
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-10403 sparse compound index should really b... Closed
Participants:

 Description   

It looks like there's a uassert in indexkey.cpp, but it isn't correct. I think it should be:

uassert( 13529 , "sparse only works for single field keys" , ! _sparse || _nFields == 1 );

Example:

admin> db.foo.ensureIndex(

{x:1,y:1}

,

{sparse:true,unique:true}

)
admin> db.foo.getIndexes()
[
{
"v" : 1,
"key" :

{ "_id" : 1 }

,
"ns" : "admin.foo",
"name" : "id"
},
{
"v" : 1,
"key" :

{ "x" : 1, "y" : 1 }

,
"unique" : true,
"ns" : "admin.foo",
"name" : "x_1_y_1",
"sparse" : true
}
]



 Comments   
Comment by Randolph Tan [ 15/Aug/13 ]

Current master branch allows compound sparse index (although it may not fit some other use cases - see SERVER-10403). The assert was also removed from the code.

Comment by Eliot Horowitz (Inactive) [ 01/Oct/11 ]

multi key sparse indexes do work
may just be a doc bug and need to remove assert

Generated at Thu Feb 08 03:04:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.