S
S
sandrain2016-07-20 12:24:56
MongoDB
sandrain, 2016-07-20 12:24:56

How to query nested attributes in Mongo?

I have the following data set:

{
    "_id" : ObjectId("55d48d91e9fb6a71188b4567"),
    "data" : {
        "10104" : {
            "title" : "Abgasanlage/Turbolader/Lambda-Sonde ",
            "sort_title" : "abgasanlage/turbolader/lambda-sonde ",
            "node_id" : "10104",
            "parent_id" : "10001",
            "items" : [ 
                {
                    "assemblyGroupNodeId" : "12551",
                    "parentNodeId" : "10104",
                    "assemblyGroupName" : "Abgasklappe",
                    "alias" : "abgasklappe",
                }, 
//....
}

I'm trying to make a request - pull all records with assemblyGroupNodeId : 12551
db.collection.find({"data.items.assemblyGroupNodeId": "12551"})

Does not work. Can anyone come across?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Belyaev, 2016-07-20
@sandrain

Data has no items
Data has 10104 which has items

S
sandrain, 2016-07-20
@sandrain

Here the guys suggest (@bingo347) that you can specify a more accurate index.
And without it it is impossible? just in my case 10104 is just what you are looking for

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question