【问题标题】:Query taking so long neo4j to merge relationships查询需要很长时间 neo4j 才能合并关系
【发布时间】:2019-09-26 02:58:27
【问题描述】:
LOAD CSV FROM 'file:///relationships.tsv' as row
FIELDTERMINATOR '\t'
WITH row
MATCH (a:actor {id: row[2]}), (b:movie {id: row[0]}) MERGE (a)-[r:ACTED_IN]->(b)

文件看起来像这样:

tt0015637   8   nm0166876   actor   \N  ["Bull Harding"]
tt2450056   2   nm0000616   actor   \N  ["Dr. Mc Millan"]
tt1053424   1   nm0000179   actor   \N  ["Remy"]
tt0062535   1   nm0176061   actor   \N  ["Ric"]
tt0016908   3   nm0384944   actor   \N  ["Capt. Blackwell"]
tt0020459   4   nm0176971   actor   \N  ["Pete"]
tt1300155   1   nm1497548   actor   \N  ["Moon Blake"]

row[0] 是电影的 ID。 row[2] 是演员的 id

此外,我还希望 row[3] 只是演员。有时会有类似的东西

tt0033839   5   nm0377613   director    \N  \N

我希望 row[3] 只是我尝试过的演员

LOAD CSV FROM 'file:///relationships.tsv' as row
FIELDTERMINATOR '\t'
WITH row
MATCH (a:actor {id: row[2]}), (b:movie {id: row[0]}) MERGE (a)-[r:ACTED_IN]->(b)
WHERE row[3] == 'actor'

但这给了我 Neo.ClientError.Statement.SyntaxError: Invalid input 'H': expected 'i/I' (line 5, column 2 (offset: 161)) "WHERE 行[3] == '演员'

我添加了所有属性 name 和 id 与电影相同的演员。

为什么这不起作用?

【问题讨论】:

  • 这:== 不是有效的 Cypher 运算符。 Cypher 在评估谓词时使用 = 代替。

标签: database neo4j cypher


【解决方案1】:

确保您在 :actor(id):movie(id) 上创建了索引。

并将WHERE 语句放在WITH 语句之后,所以首先您将过滤行然后执行操作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-06
    • 1970-01-01
    • 2019-07-02
    • 2016-04-22
    • 2021-12-25
    • 2016-06-17
    • 2021-06-15
    • 2011-01-17
    相关资源
    最近更新 更多