a. db.crimes.find({$or:[{"properties.method":"GUN"},{"properties.method":"KNIFE"}]}).count(); db.crimes.find({"properties.method":{$in:["GUN","KNIFE"]}}).count(); b. db.crimes.find({$or:[{"properties.report_date":{$regex:/^2018-06/}}, {"properties.report_date":{$regex:/^2018-07/}}, {"properties.report_date":{$regex:/^2018-08/}}] }).count() c. db.crimes.find({},{_id:0,properties:1}).sort({"properties.report_date":1}).limit(3) d. db.crimes.update({"properties.neighborho":"Cluster 6"},{$set:{"properties.neighborho":"Cluster 666"}}) db.crimes.update({"properties.neighborho":"Cluster 6"},{$set:{"properties.neighborho":"Cluster 666"}},{multi=true}) e. db.crimes.find({"properties.offense":{$regex:/THEFT/}}).count() f. db.crimes.aggregate([ { $project : { "properties.district": 1, _id: 0 } }, { $group: { _id: "$properties.district", total: { $sum:1 } } }, { $sort: {_id:1}} ]) g. db.crimes.aggregate([ { $project : { "properties.shift": 1, "properties.method": 1, _id: 0 } }, { $match: { "properties.method": "GUN" } }, { $group: { _id: "$properties.shift", total: { $sum:1 } } }, { $sort: {_id:1}} ]) h. db.crimes.aggregate([ { $project : { "properties.shift": 1, "properties.offense": 1, _id: 0 } }, { $match: { "properties.offense": "SEX ABUSE" } }, { $group: { _id: "$properties.shift", total: { $sum:1 } } }, { $sort: {_id:1}} ]) i. db.crimes.aggregate([ { $project : { "properties.offense": 1, _id: 0 } }, { $group: { _id: "$properties.offense", total: { $sum:1 } } }, { $sort: {_id:1}} ]) j. db.crimes.find({"properties.offense":{$in:["ROBBERY","ARSON"]}}).count() k. db.crimes.aggregate([ { $group: { _id: "$properties.district", totalcrimes: { $sum:1 } } }, { $group: { _id: null, avg: { $avg: '$totalcrimes' } } } ]) l. // 0%, c'est un piège : db.crimes.aggregate([ { $match: {"properties.report_date": {$regex:/^2018-08/}} }, { $group: { _id: "$properties.offense", total: { $sum:1 } } }, ]) m. db.crimes.aggregate([ { $project : { "properties.district": 1, _id: 0 } }, { $group: { _id: "$properties.district", total: { $sum:1 } } }, { $sort: {"total":-1}}, { $limit: 1 } ]) n. db.crimes.deleteMany({"properties.offense": "ARSON"}) o. // creer un index en 1er lieu db.crimes.createIndex({"geometry":"2dsphere"}) // puis la requête db.crimes.find({ "geometry": { $near: { $geometry: { type: "Point" , coordinates: [ -77.03652979999998, 38.8976763 ] }, $maxDistance: 500 }} }).count() p. // distinct db.crimes.distinct("properties.offense",{ "geometry": { $near: { $geometry: { type: "Point" , coordinates: [ -77.03652979999998, 38.8976763 ] }, $maxDistance: 500 }} },{"properties.offense":1, "_id":0}) q. // Portez attention au champ result... db.crimes.aggregate([ { $geoNear: { near: { type: "Point", coordinates: [ -77.009003, 38.889931 ] }, key: "geometry", distanceField: "result.distance", includeLocs: "result.location", num: 10, spherical: true } } ])