neo4j版本2.3.1
Stoptime.stop_sequence
和Stoptime.key
上存在索引。
Stoptime.stop_sequence
是数字。
图表:
(Stoptime)-[:PART_OF]->(Trip)
说明:
//USING PERIODIC COMMIT 1000
PROFILE
load csv with headers from "file:///path/to/csv" as csv with csv limit 0
match (s1:Stoptime{key:(csv.trip_id + csv.stop_id)})-[:PART_OF]->(trip:Trip), (s2:Stoptime)-[:PART_OF]->(trip)
where s2.stop_sequence = s1.stop_sequence + 1
create (s1)-[:PRECEDES]->(s2);
生成的配置文件如下所示:
+-----------------------+------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| Operator | Rows | DB Hits | Identifiers | Other |
+-----------------------+------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| +EmptyResult | 0 | 0 | | |
| | +------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| +UpdateGraph | 0 | 0 | anon[188], anon[227], anon[311], csv, s1, s2, trip | CreateRelationship |
| | +------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| +Eager | 0 | 0 | anon[188], anon[227], csv, s1, s2, trip | |
| | +------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| +Filter | 0 | 0 | anon[188], anon[227], csv, s1, s2, trip | Ands(trip:Trip, s2:Stoptime, s2.stop_sequence == Add(s1.stop_sequence,{ AUTOINT0}), NOT(anon[188] == anon[227])) |
| | +------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| +SimplePatternMatcher | 0 | 0 | anon[188], anon[227], csv, s1, s2, trip | |
| | +------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| +SchemaIndex | 0 | 0 | csv, s1 | Add(csv.trip_id,csv.stop_id); :Stoptime(key) |
| | +------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| +Slice | 0 | 0 | csv | Literal(0) |
| | +------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| +LoadCSV | 1 | 0 | csv | |
+-----------------------+------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+
在这种情况下如何将MATCH + WHERE与CREATE分开以删除EAGER?
在将预先构建的关系填充到图表中之前,我唯一可以预先处理CSV,并将其定义为新的PRECEDES
关系吗?或者有没有办法用更好的MATCH建立连续关系。
答案 0 :(得分:0)
Cypher 3.x不再有此问题。 (但是,如果您在Cypher 2.3兼容模式下运行,它将不会消失)
因此,任何有此问题的人,我建议升级到Neo4j的最新版本。