我有两个收藏夹;一个是车辆(10 Kb):
{
"_id" : ObjectId("5d23c9fed6f3def48ad9e5e6"),
"Accident_Index" : "201501BS70001",
"accyr" : 2015,
"Vehicle_Reference" : 1,
"Vehicle_Type" : 19,
"Towing_and_Articulation" : 0,
"Vehicle_Manoeuvre" : 9,
"Vehicle_Location-Restricted_Lane" : 0,
"Junction_Location" : 8,
"Skidding_and_Overturning" : 0,
"Hit_Object_in_Carriageway" : 0,
"Vehicle_Leaving_Carriageway" : 0,
"Hit_Object_off_Carriageway" : 0,
"1st_Point_of_Impact" : 1,
"Was_Vehicle_Left_Hand_Drive" : 1,
"Journey_Purpose_of_Driver" : 1,
"Sex_of_Driver" : 1,
"Age_Band_of_Driver" : -1,
"Engine_Capacity_(CC)" : 2143,
"Propulsion_Code" : 2,
"Age_of_Vehicle" : 4,
"Driver_IMD_Decile" : -1,
"Driver_Home_Area_Type" : -1,
"make" : "MERCEDES-BENZ",
"model" : "SPRINTER 310 CDI"
}
另一个是事故(250mb):
{
"_id" : ObjectId("5d23c9f3d6f3def48ad7c23c"),
"Accident_Index" : "201501BS70001",
"Location_Easting_OSGR" : 524420,
"Location_Northing_OSGR" : 181080,
"Longitude" : -0.208327,
"Latitude" : 51.514952,
"Police_Force" : 1,
"Accident_Severity" : 3,
"Number_of_Vehicles" : 1,
"Number_of_Casualties" : 1,
"Date" : "13/01/2015",
"Day_of_Week" : 3,
"Time" : "07:40",
"Local_Authority_(District)" : 12,
"Local_Authority_(Highway)" : "E09000020",
"1st_Road_Class" : 4,
"1st_Road_Number" : 450,
"Road_Type" : 6,
"Speed_limit" : 30,
"Junction_Detail" : 6,
"Junction_Control" : 4,
"2nd_Road_Class" : 6,
"2nd_Road_Number" : 0,
"Pedestrian_Crossing-Human_Control" : 0,
"Pedestrian_Crossing-Physical_Facilities" : 0,
"Light_Conditions" : 1,
"Weather_Conditions" : 1,
"Road_Surface_Conditions" : 2,
"Special_Conditions_at_Site" : 0,
"Carriageway_Hazards" : 0,
"Urban_or_Rural_Area" : 1,
"Did_Police_Officer_Attend_Scene_of_Accident" : 2,
"LSOA_of_Accident_Location" : "E01002874"
}
现在,我正在尝试对事故收集运行汇总功能,并创建一个名为 combined 的新收集,但是合并需要花费很多时间。这是我的聚合函数:
db.accidents.aggregate([
{$lookup:{
from:"vehicles",
localField: "Accident_Index",
foreignField: "Accident_Index",
as: "Vehicles"}
},
{$unwind: "$Vehicles"},
{$project: {
Accident_Index:1,
Accident_Severity:1,
_id:0,
Vehicle_Type: "$vehicles.Vehicle_Type"}
},
{$out:"combined"}
])
你知道怎么了吗?