DhanaLaxshmi
DhanaLaxshmi

Reputation: 424

mongodb find query is not working

I have a collection facialAnalysisConfiguration

the data in the collection is as shown below

  {

        "details": {
            "date": ISODate("2018-04-03T11:54:53.916+0000"),
            "statusText": "OK",
            "config": {
                "headers": {
                    "Content-Type": "application/json;charset=utf-8",
                    "Accept": "application/json, text/plain, */*"
                },
                "data": {
                    "image": ""
                },
                "url": "/storeIncommingImages",
                "jsonpCallbackParam": "callback",
                "transformResponse": [
                    null
                ],
                "transformRequest": [
                    null
                ],
                "method": "POST"
            },
            "status": NumberInt(200),
            "data": {
                "FaceModelVersion": "2.0",
                "OrientationCorrection": "ROTATE_0",
                "FaceRecords": [{
                    "FaceDetail": {
                        "Confidence": 99.9393310546875,
                        "Quality": {
                            "Sharpness": 99.80813598632812,
                            "Brightness": 12.500774383544922
                        },
                        "Pose": {
                            "Pitch": -5.199888229370117,
                            "Yaw": -3.2905712127685547,
                            "Roll": 7.3970136642456055
                        },

                        "Emotions": [{
                                "Confidence": 44.84807205200195,
                                "Type": "CONFUSED"
                            },
                            {
                                "Confidence": 17.345977783203125,
                                "Type": "CALM"
                            },
                            {
                                "Confidence": 6.819361686706543,
                                "Type": "SURPRISED"
                            }
                        ],
                        "MouthOpen": {
                            "Confidence": 99.90953826904297,
                            "Value": false
                        },
                        "EyesOpen": {
                            "Confidence": 99.79545593261719,
                            "Value": true
                        },
                        "Mustache": {
                            "Confidence": 99.68254852294922,
                            "Value": false
                        },
                        "Beard": {
                            "Confidence": 95.8907470703125,
                            "Value": false
                        },
                        "Gender": {
                            "Confidence": 99.9259262084961,
                            "Value": "Male"
                        },
                        "Sunglasses": {
                            "Confidence": 99.36517333984375,
                            "Value": false
                        },
                        "Eyeglasses": {
                            "Confidence": 99.82603454589844,
                            "Value": true
                        },
                        "Smile": {
                            "Confidence": 50.894676208496094,
                            "Value": false
                        },
                        "AgeRange": {
                            "High": NumberInt(15),
                            "Low": NumberInt(10)
                        },
                        "BoundingBox": {
                            "Top": 0.4294871687889099,
                            "Left": 0.29567307233810425,
                            "Height": 0.39743590354919434,
                            "Width": 0.30048078298568726
                        }
                    },
                    "Face": {
                        "Confidence": 99.9393310546875,
                        "ExternalImageId": "belgium_medium_gender",
                        "ImageId": "65e5b4f0-f803-5592-9c7c-95d3b983290b",
                        "BoundingBox": {
                            "Top": 0.4294871687889099,
                            "Left": 0.29567307233810425,
                            "Height": 0.39743590354919434,
                            "Width": 0.30048078298568726
                        },
                        "FaceId": "a875fb3b-4257-4cf0-951b-3d4892aabe41"
                    }
                }]
            }
        },
        "__v": NumberInt(0)
    }

how to get all the records where the Emotions.type value is "CONFUSED"

please note the object navigation is as shown below details.data.FaceRecords[0].FaceDetail.Confidence

Tried writing few quires using aggregation but unable to find please suggest a way to approach it

Upvotes: 0

Views: 48

Answers (1)

Sivaprasanna Sethuraman
Sivaprasanna Sethuraman

Reputation: 4132

I see conflicts in your description. You have mentioned that you want to get all the records where the Emotions.type value is "CONFUSED" but later have specified a object navigation (FaceDetail.Confidence).

Regardless, the below query should return all the matching records whose Emotions.Type is CONFUSED.

db.facialAnalysisConfiguration.find( { "details.data.FaceRecords.FaceDetail.Emotions.Type": "CONFUSED" }

Upvotes: 2

Related Questions