【发布时间】:2013-09-11 17:19:44
【问题描述】:
我无法在图表中导入关系。
假设我有数百个已创建的唯一索引用户。然后我想创建大约 120k 个节点,每个节点都通过关系链接到某个用户。
很遗憾,我找不到批量导入的方法。我正在尝试使用 neography ruby gem 来执行此操作,但由于我对这种环境非常陌生,如果需要,我不介意使用其他方式。
我尝试了什么:
@neo.batch(
[:get_node_index, 'user', 'user_id', '1'], #attempt to get the node from index
[:create_node, {"foo => 'bar'}],
[:create_relationship, "has" , "{0}", "{1}"]
) # => fails
,
@neo.batch(
[:create_unique_node, "user", "user_id", "1"], #attempt to create or get the node
[:create_node, {"foo" => "bar"}],
[:create_relationship, "has", "{0}", "{1}"]
) # => fails.
请注意,仍然可以单独批处理一些 create_unique_node 命令。
我可以让脚本运行的唯一方法是使用
@neo.batch(
[:create_node, {"user_id" => 1}], #works, but duplicates the node
[:create_node, {"foo" => "bar"}],
[:create_relationship, "has", "{0}", "{1}"]
) # => success
但是,这将复制我的所有用户节点,这绝对不是我想要实现的。 看来我的问题类似于this one,但是我根本不明白在创建关系时我应该如何使用索引。
任何帮助将不胜感激,在此先感谢
【问题讨论】:
-
您找到解决方案了吗?
-
我实际上使用了一些解决方法,我会发布一个答案来解释它。