【问题标题】:neo4j cypher query for csv import用于 csv 导入的 neo4j 密码查询
【发布时间】:2014-06-11 07:11:27
【问题描述】:

我正在从 csv 导入数据并使用 neo4j2.1.1。我使用以下查询来查找具有索引的节点....

LOAD CSV FROM 'file:/tmp/test.csv' AS line Start

p = node:node_auto_index(mysqlPatientId = line[0])
set p.patDob = line[8]
return p;

但我尝试了很多但总是出错--------

SyntaxException: Invalid input 'l': expected whitespace, comment, "...string..." or a parameter (line 1, column 95)
"LOAD CSV FROM 'file:/tmp/10lpnew.csv' AS line Start p = node:node_auto_index(mysqlPatientId = line[0])"

提前谢谢..!!

【问题讨论】:

  • 索引查找不支持表达式,只支持参数和文字值。

标签: neo4j


【解决方案1】:

我猜LOAD CSV 不能很好地与旧索引配合使用。因此,我建议在所有具有mysqlPatientId 的节点上设置标签:

MATCH (n) WHERE HAS(n.mysqlPatientId) SET n :Patient

如果您有大量此类节点,请考虑使用 SKIP 和 LIMIT 以使用合理的事务大小,例如

MATCH (n) WHERE HAS(n.mysqlPatientId) SET n :Patient SKIP 0 LIMIT 20000
MATCH (n) WHERE HAS(n.mysqlPatientId) SET n :Patient SKIP 20000 LIMIT 20000
MATCH (n) WHERE HAS(n.mysqlPatientId) SET n :Patient SKIP 40000 LIMIT 20000

完成后,创建架构索引:

CREATE INDEX ON :Patient(mysqlPatientId)

接下来是在neo4j.properties 中切换自动索引。

导入 CSV 不应该像这样工作:

LOAD CSV FROM 'file:/tmp/test.csv' AS line Start
MERGE (p:Patient { mysqlPatientId: line[0], patDob: line[8] })

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-29
    • 1970-01-01
    • 2017-04-12
    • 1970-01-01
    • 2021-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多