嗨,我正在使用 gremlin 遍历图表,我的查询如下
g.V().match(
__.as("BaseVehicle").outE("year").as("year"),
__.as("BaseVehicle").outE("make").as("make"),
__.as("BaseVehicle").outE("model").as("model"),
__.as("year").has("Year","1982"),
__.as("make").has("MakeName","BMW"),
__.as("model").has("ModelName","R65")
).select("BaseVehicle").by("BaseVehicleID")
它采取aprox。20 秒执行。为什么要花这么多时间?
架构如下
schema.propertyKey("BaseVehicle").Int().single().create()
schema.propertyKey("ModelName").Text().single().create()
schema.propertyKey("YearID").Int().single().create()
schema.propertyKey("MakeID").Int().single().create()
schema.propertyKey("BaseVehicleID").Int().single().create()
schema.propertyKey("Year").Int().single().create()
schema.propertyKey("MakeName").Text().single().create()
schema.propertyKey("ModelID").Int().single().create()
schema.edgeLabel("year").multiple().properties("BaseVehicle", "Year").create()
schema.edgeLabel("model").multiple().properties("ModelName", "BaseVehicle").create()
schema.edgeLabel("make").multiple().properties("MakeName", "BaseVehicle").create()
schema.vertexLabel("BaseVehicle").properties("BaseVehicleID").create()
schema.vertexLabel("BaseVehicle").index("byBaseVehicleID").materialized().by("BaseVehicleID").add()
schema.vertexLabel("Year").properties("YearID").create()
schema.vertexLabel("Year").index("byYearID").materialized().by("YearID").add()
schema.vertexLabel("Year").index("YearByBaseVehicle").inE("year").by("Year").add()
schema.vertexLabel("Model").properties("ModelName", "ModelID").create()
schema.vertexLabel("Model").index("byModelID").materialized().by("ModelID").add()
schema.vertexLabel("Model").index("ModelByBaseVehicle").inE("model").by("ModelName").add()
schema.vertexLabel("Make").properties("MakeName", "MakeID").create()
schema.vertexLabel("Make").index("byMakeID").materialized().by("MakeID").add()
schema.vertexLabel("Make").index("MakeByBaseVehicle").inE("make").by("MakeName").add()
schema.edgeLabel("year").connection("BaseVehicle", "Year").add()
schema.edgeLabel("model").connection("BaseVehicle", "Model").add()
schema.edgeLabel("make").connection("BaseVehicle", "Make").add()