When using compound index and distinct on the second part of the compound index, the distinct command fails.
Example (Testdata):
consus.tag document:
{
"_id" : ObjectId("4d231bf4e175535eb49cef31"),
"shopCode" : "BD_DE",
"value" : "TKUODAIFVTYPWHCM",
"mprgs" : [
"mprg12",
"mprg19"
],
"mprgsWithPromotion" : [
"mprg12"
],
"prgs" : [
"prg4",
"prg3"
],
"prgsWithPromotion" : []
}
Indexed:
use consus
db.tag.ensureIndex(
)
db.tag.ensureIndex(
)
db.tag.ensureIndex(
)
Query:
db.tag.distinct('value',
{shopCode: 'BD_DE'});
Result:
Tue Jan 4 15:26:14 uncaught exception: distinct failed: {
"errmsg" : "exception: assertion db/clientcursor.cpp:307",
"code" : 0,
"ok" : 0
}
Console:
Tue Jan 4 15:16:40 [conn76] consus Assertion failure x == 0 db/clientcursor.cpp 307
0x1000755f2 0x10008493e 0x1001c4a8d 0x10035b9cc 0x10033c931 0x10033db43 0x10016dca4 0x10017266c 0x1002a9e98 0x1002b52af 0x100417bd5 0x10042d0e4 0x7fff8695d456 0x7fff8695d309
0 mongod 0x00000001000755f2 _ZN5mongo12sayDbContextEPKc + 178
1 mongod 0x000000010008493e _ZN5mongo8assertedEPKcS1_j + 286
2 mongod 0x00000001001c4a8d _ZN5mongo12ClientCursor15getFieldsDottedERKSsRSt3setINS_11BSONElementENS_26BSONElementCmpWithoutFieldESaIS4_EE + 413
3 mongod 0x000000010035b9cc _ZN5mongo15DistinctCommand3runERKSsRNS_7BSONObjERSsRNS_14BSONObjBuilderEb + 1516
4 mongod 0x000000010033c931 _ZN5mongo11execCommandEPNS_7CommandERNS_6ClientEiPKcRNS_7BSONObjERNS_14BSONObjBuilderEb + 1425
5 mongod 0x000000010033db43 _ZN5mongo12_runCommandsEPKcRNS_7BSONObjERNS_10BufBuilderERNS_14BSONObjBuilderEbi + 1699
6 mongod 0x000000010016dca4 _ZN5mongo11runCommandsEPKcRNS_7BSONObjERNS_5CurOpERNS_10BufBuilderERNS_14BSONObjBuilderEbi + 52
7 mongod 0x000000010017266c ZN5mongo8runQueryERNS_7MessageERNS_12QueryMessageERNS_5CurOpES1 + 9852
8 mongod 0x00000001002a9e98 _ZN5mongo13receivedQueryERNS_6ClientERNS_10DbResponseERNS_7MessageE + 568
9 mongod 0x00000001002b52af _ZN5mongo16assembleResponseERNS_7MessageERNS_10DbResponseERKNS_8SockAddrE + 5055
10 mongod 0x0000000100417bd5 _ZN5mongo10connThreadEPNS_13MessagingPortE + 421
11 mongod 0x000000010042d0e4 thread_proxy + 132
12 libSystem.B.dylib 0x00007fff8695d456 _pthread_start + 331
13 libSystem.B.dylib 0x00007fff8695d309 thread_start + 13
stats():
{
"ns" : "consus.tag",
"count" : 302,
"size" : 158412,
"avgObjSize" : 524.5430463576159,
"storageSize" : 179712,
"numExtents" : 3,
"nindexes" : 4,
"lastExtentSize" : 137216,
"paddingFactor" : 1,
"flags" : 1,
"totalIndexSize" : 352256,
"indexSizes" :
,
"ok" : 1
}