CREATE (slc:Airport {abbr:‘SLC’, id:14869, name:‘SALT LAKE CITY INTERNATIONAL’}) CREATE (oak:Airport {abbr:‘OAK’, id:13796, name:‘METROPOLITAN OAKLAND INTERNATIONAL’}) CREATE (bur:Airport {abbr:‘BUR’, id:10800, name:‘BOB HOPE’}) CREATE (f2:Flight {flight_num:6147, day:2, month:1, weekday:6, year:2016}) CREATE (f9:Flight {flight_num:6147, day:9, month:1, weekday:6, year:2016}) CREATE (f16:Flight {flight_num:6147, day:16, month:1, weekday:6, year:2016}) CREATE (f23:Flight {flight_num:6147, day:23, month:1, weekday:6, year:2016}) CREATE (f30:Flight {flight_num:6147, day:30, month:1, weekday:6, year:2016}) CREATE (f2)-[:DESTINATION {arr_delay:-13, taxi_time:9}]->(oak) CREATE (f9)-[:DESTINATION {arr_delay:-8, taxi_time:4}]->(bur) CREATE (f16)-[:DESTINATION {arr_delay:-30, taxi_time:4}]->(slc) CREATE (f23)-[:DESTINATION {arr_delay:-21, taxi_time:3}]->(slc) CREATE (f30)-[:DESTINATION]->(slc)
在关系上建立了索引 MATCH (:Flight)-[r:DESTINATION]->(:Airport) CALL apoc.index.addRelationship(r,[‘taxi_time’]) RETURN count(*)
进行查询 CALL apoc.index.relationships(‘DESTINATION’,‘taxi_time:11’) YIELD rel, start AS flight, end AS airport RETURN flight.flight_num, airport.name;
疑问? taxi_time支持范围查找吗。比如我想查询taxi_time>11的怎么查询。还是说不支持范围
可以这样实现: CALL apoc.index.relationships(‘DESTINATION’,‘taxi_time:[1 TO 4]’) YIELD rel, start AS flight, end AS airport RETURN flight.flight_num, airport.name;