Py2neo Neo4j的批量提交错误 [英] Py2neo Neo4j Batch submit error

查看:391
本文介绍了Py2neo Neo4j的批量提交错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大约140万个节点的数据的JSON文件,我想构建一个Neo4j的图形数据库。我试图用py2neo的批量提交功能。我的code是如下:

I have a json file with data of around 1.4 million nodes and I wanted to construct a Neo4j graph database for that. I tried to use py2neo's batch submit function. My code is as follows:

# the variable words is a list containing node names
from py2neo import neo4j
batch = neo4j.WriteBatch(graph_db)
nodedict = {}
# I decided to use a dictionary because I would be creating relationships
# by referring to the dictionary entries later
for i in words:
    nodedict[i] = batch.create({"name":i})
results = batch.submit()

示出的错误是如下:

The error shown is as follows:

Traceback (most recent call last):
  File "test.py", line 36, in <module>
    results = batch.submit()
  File "/usr/lib/python2.6/site-packages/py2neo/neo4j.py", line 2116, in submit
    for response in self._submit()
  File "/usr/lib/python2.6/site-packages/py2neo/neo4j.py", line 2085, in _submit
    for id_, request in enumerate(self.requests)
  File "/usr/lib/python2.6/site-packages/py2neo/rest.py", line 427, in _send
    return self._client().send(request)
  File "/usr/lib/python2.6/site-packages/py2neo/rest.py", line 364, in send
    return Response(request.graph_db, rs.status, request.uri, rs.getheader("Loc$
  File "/usr/lib/python2.6/site-packages/py2neo/rest.py", line 278, in __init__
    raise SystemError(body)
SystemError: None

任何人可以告诉我究竟发生在这里?是否有什么关系的事实,批量查询是pretty大?如果是这样,可以做什么?提前致谢! :)

Can anybody please tell me what exactly is happening here? Does it have anything to do with the fact that the batch query is pretty large? If so, what can be done? Thanks in advance! :)

推荐答案

因此​​,这里是我想通了(感谢这个问题:<一href=\"http://stackoverflow.com/questions/17902741/py2neo-neo4j-system-error-create-batch-nodes-relationships\">py2neo - Neo4j的 - 系统错误 - 创建批处理节点/关系):

So here's what I figured out (Thanks to this question: py2neo - Neo4j - System Error - Create Batch Nodes/Relationships):

该py2neo批量提交功能,有它在,可以进行查询方面的局限性。虽然,我是不是能够得到上限的确切数额,我试图限制我的每批次查询到5000的号码,我决定运行下面的一块code的:

The py2neo batch submit function has it's own limitations in terms of queries that can be made. While, I wasn't able to get a exact amount on the upper limit, I tried to limit my number of queries per batch to 5000. So I decided to run the following piece of code:

# the variable words is a list containing node names
from py2neo import neo4j
batch = neo4j.WriteBatch(graph_db)
nodedict = {}
# I decided to use a dictionary because I would be creating relationships
# by referring to the dictionary entries later

for index, i in enumerate(words):
    nodedict[i] = batch.create({"name":i})
    if index%5000 == 0:
        batch.submit()
        batch = neo4j.WriteBatch(graph_db) # As stated by Nigel below, I'm creating a new batch
batch.submit() #for the final batch

这样的话,我送一批请求(大小5K查询),并成功地能得到我的整个图形创建!

This way, I sent batch requests (of size 5k queries) and was successfully able to get my entire graph created!

这篇关于Py2neo Neo4j的批量提交错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆