搜索整个集合而不知道结构

时间:2014-10-17 02:37:36

标签: mongodb mongoose mongodb-query

如何在非结构化的架构上进行正则表达式搜索。

这是我的架构:

var phoneSchema = mongoose.Schema({
    name: String,
    img: String,
    specs: []   
});

这是数据的示例

{
    "name": "Apple iPad mini Wi-Fi + Cellular",
    "img": "http://cdn2.gsmarena.com/vv/bigpic/apple-ipad-mini-final.jpg",
    "_id": {
        "$oid": "543f40c5427c1034a905d5af"
    },
    "specs": [
        {
            "description": "[{\"criteria\":\"2G Network\",\"description\":\"GSM 850 / 900 / 1800 / 1900  - A1454; A1455\"},{\"criteria\":\" \",\"description\":\"CDMA 800 / 1900 / 2100  - A1455\"},{\"criteria\":\"3G Network\",\"description\":\"HSDPA 850 / 900 / 1900 / 2100  - A1454; A1455\"},{\"criteria\":\"4G Network\",\"description\":\"LTE 700 MHz Class 17 / 1700 / 2100  - A1454\"},{\"criteria\":\" \",\"description\":\"LTE 700 / 850 / 1800 / 1900 / 2100  - A1455\"},{\"criteria\":\"SIM\",\"description\":\"Nano-SIM\"},{\"criteria\":\"Announced\",\"description\":\"2012, October\"},{\"criteria\":\"Status\",\"description\":\"Available. Released 2012, November\"}]",
            "title": "General"
        },
        {
            "description": "[{\"criteria\":\"Dimensions\",\"description\":\"200 x 134.7 x 7.2 mm (7.87 x 5.30 x 0.28 in)\"},{\"criteria\":\"Weight\",\"description\":\"312 g (11.01 oz)\"}]",
            "title": "Body"
        },
        {
            "description": "[{\"criteria\":\"Type\",\"description\":\"LED-backlit IPS LCD capacitive touchscreen, 16M colors\"},{\"criteria\":\"Size\",\"description\":\"768 x 1024 pixels, 7.9 inches (~162 ppi pixel density)\"},{\"criteria\":\"Multitouch\",\"description\":\"Yes\"},{\"criteria\":\"Protection\",\"description\":\"Oleophobic coating\"}]",
            "title": "Display"
        },
        {
            "description": "[{\"criteria\":\"Alert types\",\"description\":\"N/A\"},{\"criteria\":\"Loudspeaker \",\"description\":\"Yes, with stereo speakers\"},{\"criteria\":\"3.5mm jack \",\"description\":\"Yes\"}]",
            "title": "Sound"
        },
        {
            "description": "[{\"criteria\":\"Card slot\",\"description\":\"No\"},{\"criteria\":\"Internal\",\"description\":\"16/32/64 GB, 512 MB RAM\"}]",
            "title": "Memory"
        },
        {
            "description": "[{\"criteria\":\"GPRS\",\"description\":\"Yes\"},{\"criteria\":\"EDGE\",\"description\":\"Yes\"},{\"criteria\":\"Speed\",\"description\":\"DC-HSDPA, 42 Mbps; HSDPA, 21 Mbps; HSUPA, 5.76 Mbps, LTE, 100 Mbps; EV-DO Rev. A, up to 3.1 Mbps\"},{\"criteria\":\"WLAN\",\"description\":\"Wi-Fi 802.11 a/b/g/n, dual-band\"},{\"criteria\":\"Bluetooth\",\"description\":\"v4.0, A2DP, EDR\"},{\"criteria\":\"USB\",\"description\":\"v2.0\"}]",
            "title": "Data"
        },
        {
            "description": "[{\"criteria\":\"Primary\",\"description\":\"5 MP, 2592 х 1944 pixels, autofocus\"},{\"criteria\":\"Features\",\"description\":\"Geo-tagging, touch focus, face detection\"},{\"criteria\":\"Video\",\"description\":\"1080p@30fps\"},{\"criteria\":\"Secondary\",\"description\":\"1.2 MP, 720p@30fps, face detection, FaceTime over Wi-Fi or Cellular\"}]",
            "title": "Camera"
        },
        {
            "description": "[{\"criteria\":\"OS\",\"description\":\"iOS 6, upgradable to iOS 7.1.2, upgradable to iOS 8.0.2\"},{\"criteria\":\"Chipset\",\"description\":\"Apple A5\"},{\"criteria\":\"CPU\",\"description\":\"Dual-core 1 GHz Cortex-A9\"},{\"criteria\":\"GPU\",\"description\":\"PowerVR SGX543MP2\"},{\"criteria\":\"Sensors\",\"description\":\"Accelerometer, gyro, compass\"},{\"criteria\":\"Messaging\",\"description\":\"iMessage, Email, Push Email, IM\"},{\"criteria\":\"Browser\",\"description\":\"HTML5 (Safari)\"},{\"criteria\":\"Radio\",\"description\":\"No\"},{\"criteria\":\"GPS\",\"description\":\"Yes, with A-GPS, GLONASS\"},{\"criteria\":\"Java\",\"description\":\"No\"},{\"criteria\":\"Colors\",\"description\":\"Black/Slate, White/Silver\"},{\"criteria\":\" \",\"description\":\"- Siri natural language commands and dictation\\n\\n- iCloud cloud service\\n\\n- Twitter and Facebook integration\\n\\n- Maps\\n\\n- Audio/video player/editor\\n\\n- Photo viewer/editor\\n\\n- Voice memo\\n\\n- TV-out\\n\\n- Document viewer\\n\\n- Predictive text input\"}]",
            "title": "Features"
        },
        {
            "description": "[{\"criteria\":\" \",\"description\":\"Non-removable Li-Po 4490 mAh battery (16.7 Wh)\"},{\"criteria\":\"Stand-by\",\"description\":\"\"},{\"criteria\":\"Talk time\",\"description\":\"Up to 10 h (multimedia)\"}]",
            "title": "Battery"
        },
        {
            "description": "[{\"criteria\":\"Price group\",\"description\":\"http://cdn2.gsmarena.com/vv/price/pg7.gif\"}]",
            "title": "Misc"
        },
        {
            "description": "[{\"criteria\":\"Display\",\"description\":\"\\nContrast ratio: 812:1 (nominal)\"},{\"criteria\":\"Loudspeaker\",\"description\":\"\\nVoice 68dB / Noise 65dB / Ring 75dB\"},{\"criteria\":\"Audio quality\",\"description\":\"\\nNoise -82.8dB / Crosstalk -80.8dB\"}]",
            "title": "Tests"
        }
    ],
    "__v": 0
}

假设我的查询是“Noise 65dB”。它应该归还这款手机。 有人可以帮我查询结构假设我有规格作为数组,但不知道任何内部内容。

由于

0 个答案:

没有答案