[SERVER-23079] Why sub document cannot match index? Created: 11/Mar/16  Updated: 16/Mar/16  Resolved: 16/Mar/16

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

Type: Bug Priority: Major - P3
Reporter: raylynn Assignee: Kelsey Schubert
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

WINDOWS2008 R2


Issue Links:
Duplicate
duplicates SERVER-15086 Allow for efficient range queries ove... Closed
Operating System: ALL
Steps To Reproduce:

/* sample collection items */
{
    "_id" : ObjectId("56e1b0520ba71ca0485a386a"),
    "uid" : 9843,
    "sub" : {
        "date" : ISODate("2016-03-09T22:54:09.549+08:00"),
        "status" : "PLACE_ORDER_SUCCESS",
        "arr" : {
            "taskids" : [],
            "ids" : [ 
                "56c56639ef68fc0e28524aab", 
                "56c5663aef68fc0e28524ab6", 
                "56c5663aef68fc0e28524ab7", 
                "56c5663aef68fc0e28524ab8", 
                "56c5663aef68fc0e28524ab9"
            ]
        }
    }
}
 
/* sample index */
{
    "uid" : -1,
    "sub.status" : 1,
    "sub.arr.ids" : 1,
    "sub.date" : 1
}
 
 
 
/* sample search explain */
db.getCollection('sample').find({    "uid" : 9843,
    "sub.date" :  new Date(1456239231000),
    "sub.status" : "PLACE_ORDER_SUCCESS",
    "sub.arr.ids" : "56c56639ef68fc0e28524aab"
 
    }).explain()
 
 
 
/* sample index have 2 miss */
{
    "uid" : [ 
        "[9843.0, 9843.0]"
    ],
    "sub.status" : [ 
        "[MinKey, MaxKey]"
    ],
    "sub.arr.ids" : [ 
        "[\"56c56639ef68fc0e28524aab\", \"56c56639ef68fc0e28524aab\"]"
    ],
    "sub.date" : [ 
        "[MinKey, MaxKey]"
    ]
}
 
/* sample_root collection items */
 
{
    "_id" : ObjectId("56e1b0520ba71ca0485a386a"),
    "uid" : 9843,
    "date" : ISODate("2016-03-09T22:54:09.549+08:00"),
    "status" : "PLACE_ORDER_SUCCESS",
    "arr" : {
        "taskids" : [],
        "ids" : [ 
            "56c56639ef68fc0e28524aab", 
            "56c5663aef68fc0e28524ab6", 
            "56c5663aef68fc0e28524ab7", 
            "56c5663aef68fc0e28524ab8", 
            "56c5663aef68fc0e28524ab9"
        ]
    }
}
 
 
 
 
/* sample_root index */
 
{
    "uid" : -1,
    "status" : 1,
    "arr.ids" : 1,
    "date" : 1
}
 
 
 
/* sample_root search explain */
db.getCollection('sample_root').find({    "uid" : 9843,
    "date" :  new Date(1456239231000),
    "status" : "PLACE_ORDER_SUCCESS",
    "arr.ids" : "56c56639ef68fc0e28524aab"
 
    }).explain()
 
 
/* sample_root match all */
{
    "uid" : [ 
        "[9843.0, 9843.0]"
    ],
    "status" : [ 
        "[\"PLACE_ORDER_SUCCESS\", \"PLACE_ORDER_SUCCESS\"]"
    ],
    "arr.ids" : [ 
        "[\"56c56639ef68fc0e28524aab\", \"56c56639ef68fc0e28524aab\"]"
    ],
    "date" : [ 
        "[new Date(1456239231000), new Date(1456239231000)]"
    ]
}

Participants:

 Description   

I create one test collection named sample and sample_root.
sample_root all property is in root. and sample some property inside at sub document.
They are create same index.
so, when I search and explain it, I saw that index match are difference.
so what happend?

how can I match sub document index?

attach all code in here:



 Comments   
Comment by Kelsey Schubert [ 16/Mar/16 ]

Hi tianwei02,

Thank you for reporting this issue. This behavior is expected and an improvement is tracked in SERVER-15086.

Please review the comments on SERVER-15086 for additional information. In particular, please read Dave's comment, which describes this behavior.

Kind regards,
Thomas

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