0

py2neo を使用して、Neo4j データベースにデータをダンプします。

これとともに

batch = neo4j.WriteBatch(graph_db)
batch.create(node(name="Alice"))
batch.create(node(name="Bob"))
batch.create(rel(0, "KNOWS", 1))
results = batch.submit()

同じバッチ内で新しいノードを使用して関係を作成できます。

ただし、このようなバッチの前に既に作成されているノードとの関係を作成しようとすると:

n = graph_db.create({"name": "Smith"})
batch = neo4j.WriteBatch(graph_db)
batch.create(node(name="Alice"))
batch.create(rel(0, "KNOWS", n))
results = batch.submit()

失敗します*。以前に作成されたノードへのバッチ内の関係を持つノードを作成するにはどうすればよいでしょうか?

py2neo 1.5.1 と Neo4j 1.9.2 の使用

ありがとう

  • エラーメッセージ :

SystemError: {u'stacktrace': [u'org.neo4j.server.rest.batch.NonStreamingBatchOperations.invoke(NonStreamingBatchOperations.java:63)', u'org.neo4j.server.rest.batch.BatchOperations.performRequest(BatchOperations .java:188)'、u'org.neo4j.server.rest.batch.BatchOperations.parseAndPerform(BatchOperations.java:159)'、u'org.neo4j.server.rest.batch.NonStreamingBatchOperations.performBatchJobs(NonStreamingBatchOperations.java :48)'、u'org.neo4j.server.rest.web.BatchOperationService.batchProcess(BatchOperationService.java:117)'、u'org.neo4j.server.rest.web.BatchOperationService.performBatchOperations(BatchOperationService.java:72 )'、u'java.lang.reflect.Method.invoke(Method.java:606)'、u'org.neo4j.server.rest.security.SecurityFilter.doFilter(SecurityFilter.java:112)']、u'メッセージ':u'{\n "メッセージ": "入力文字列: \"5078\')]}\"",\n "例外": "BadInputException",\n "フルネーム": "org.neo4j.server.rest .repr.BadInputException",\n "stacktrace" : [ "org.neo4j.server.rest.web.RestfulGraphDatabase.extractNodeId(RestfulGraphDatabase.java:171)", "org.neo4j.server.rest.web.RestfulGraphDatabase.createRelationship (RestfulGraphDatabase.java:410)"、"java.lang.reflect.Method.invoke(Method.java:606)"、"org.neo4j.server.rest.security.SecurityFilter.doFilter(SecurityFilter.java:112)" 、「org.neo4j.server.web.Jetty6WebServer.invokeDirectly(Jetty6WebServer.java:302)」、「org.neo4j.server.rest.batch.NonStreamingBatchOperations.invoke(NonStreamingBatchOperations.java:55)」、「org.neo4j.server.rest.batch.BatchOperations.performRequest(BatchOperations.java:188)」、「org.neo4j.server.rest.batch.BatchOperations.parseAndPerform(BatchOperations.java:159)」、「org.neo4j.server.rest. batch.NonStreamingBatchOperations.performBatchJobs(NonStreamingBatchOperations.java:48)"、"org.neo4j.server.rest.web.BatchOperationService.batchProcess(BatchOperationService.java:117)"、"org.neo4j.server.rest.web.BatchOperationService. performBatchOperations(BatchOperationService.java:72)"、"java.lang.reflect.Method.invoke(Method.java:606)"、"org.neo4j.server.rest.security.SecurityFilter.doFilter(SecurityFilter.java:112) " ],\n "cause" : {\n "message" : "入力文字列: \"5078\')]}\""",\n "exception" : "NumberFormatException",\n "stacktrace" : [ "java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)", "java.lang.Long.parseLong(Long.java:441)", "java.lang.Long.parseLong( Long.java:483)"、"org.neo4j.server.rest.web.RestfulGraphDatabase.extractNodeId(RestfulGraphDatabase.java:167)"、"org.neo4j.server.rest.web.RestfulGraphDatabase.createRelationship(RestfulGraphDatabase.java: 410)"、"java.lang.reflect.Method.invoke(Method.java:606)"、"org.neo4j.server.rest.security.SecurityFilter.doFilter(SecurityFilter.java:112)"、"org.neo4j .server.web.Jetty6WebServer.invokeDirectly(Jetty6WebServer.java:302)"、"org.neo4j.server.rest.batch.NonStreamingBatchOperations.invoke(NonStreamingBatchOperations.java:55)"、"org.neo4j.server.rest.batch .BatchOperations。performRequest(BatchOperations.java:188)"、"org.neo4j.server.rest.batch.BatchOperations.parseAndPerform(BatchOperations.java:159)"、"org.neo4j.server.rest.batch.NonStreamingBatchOperations.performBatchJobs(NonStreamingBatchOperations. java:48)"、"org.neo4j.server.rest.web.BatchOperationService.batchProcess(BatchOperationService.java:117)"、"org.neo4j.server.rest.web.BatchOperationService.performBatchOperations(BatchOperationService.java:72)" ", "java.lang.reflect.Method.invoke(Method.java:606)", "org.neo4j.server.rest.security.SecurityFilter.doFilter(SecurityFilter.java:112)" ],\n "フルネーム" : "java.lang.NumberFormatException"\n }\n}', u'fullname': u'org.neo4j.server.rest.domain.BatchOperationFailedException', u'exception': u'BatchOperationFailedException'}

4

1 に答える 1

0

コード例でnは、実際には単一のノードではなく、ノードのリストが含まれます ( createメソッドの警告を参照してください)。だから、代わりに...

n = graph_db.create({"name": "Smith"})

...おそらく欲しい...

n, = graph_db.create({"name": "Smith"})
于 2013-08-23T11:12:55.943 に答える