mongodb查找查询不起作用

时间:2018-04-06 06:46:44

标签: javascript mongodb object aggregation-framework

我有一个集合facialAnalysisConfiguration

集合中的数据如下所示

  {

        "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)
    }

如何获取Emotions.type值为" CONFUSED"

的所有记录

请注意对象导航如下所示details.data.FaceRecords [0] .FaceDetail.Confidence

尝试使用聚合写几个quire但无法找到请建议一种方法来接近它

1 个答案:

答案 0 :(得分:2)

我在你的描述中看到了冲突。您已经提到要获取Emotions.type值为“CONFUSED”但后来指定了对象导航(FaceDetail.Confidence)的所有记录。

无论如何,以下查询应返回Emotions.TypeCONFUSED的所有匹配记录。

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