在Debian wheezy实例上,我刚刚将我的独立Neo4j服务器从版本2.0.2迁移到2.1.1(我在java-7-openjdk-amd64上运行。)。由于我在REST API上遇到批量查询问题:
在空数据库中,我尝试了以下测试:
首先我创建了一个节点:
curl -H Accept:application/json -H Content-Type:application/json -X POST -d '{"name":"Steven"}' http://localhost:7474/db/data/node
节点已成功创建:
{
"extensions" : {
},
"paged_traverse" : "http://localhost:7474/db/data/node/0/paged/traverse/{returnType}{?pageSize,leaseTime}",
"labels" : "http://localhost:7474/db/data/node/0/labels",
"outgoing_relationships" : "http://localhost:7474/db/data/node/0/relationships/out",
"traverse" : "http://localhost:7474/db/data/node/0/traverse/{returnType}",
"all_typed_relationships" : "http://localhost:7474/db/data/node/0/relationships/all/{-list|&|types}",
"property" : "http://localhost:7474/db/data/node/0/properties/{key}",
"all_relationships" : "http://localhost:7474/db/data/node/0/relationships/all",
"self" : "http://localhost:7474/db/data/node/0",
"outgoing_typed_relationships" : "http://localhost:7474/db/data/node/0/relationships/out/{-list|&|types}",
"properties" : "http://localhost:7474/db/data/node/0/properties",
"incoming_relationships" : "http://localhost:7474/db/data/node/0/relationships/in",
"incoming_typed_relationships" : "http://localhost:7474/db/data/node/0/relationships/in/{-list|&|types}",
"create_relationship" : "http://localhost:7474/db/data/node/0/relationships",
"data" : {
"name" : "Steven"
}
然后我尝试获取新节点:
curl -H Accept:application/json -H Content-Type:application/json -X GET http://localhost:7474/db/data/node/0
给了我预期的结果:
{
"extensions" : {
},
"paged_traverse" : "http://localhost:7474/db/data/node/0/paged/traverse/{returnType}{?pageSize,leaseTime}",
"labels" : "http://localhost:7474/db/data/node/0/labels",
"outgoing_relationships" : "http://localhost:7474/db/data/node/0/relationships/out",
"traverse" : "http://localhost:7474/db/data/node/0/traverse/{returnType}",
"all_typed_relationships" : "http://localhost:7474/db/data/node/0/relationships/all/{-list|&|types}",
"property" : "http://localhost:7474/db/data/node/0/properties/{key}",
"all_relationships" : "http://localhost:7474/db/data/node/0/relationships/all",
"self" : "http://localhost:7474/db/data/node/0",
"outgoing_typed_relationships" : "http://localhost:7474/db/data/node/0/relationships/out/{-list|&|types}",
"properties" : "http://localhost:7474/db/data/node/0/properties",
"incoming_relationships" : "http://localhost:7474/db/data/node/0/relationships/in",
"incoming_typed_relationships" : "http://localhost:7474/db/data/node/0/relationships/in/{-list|&|types}",
"create_relationship" : "http://localhost:7474/db/data/node/0/relationships",
"data" : {
"name" : "Steven"
}
但是批处理中的相同请求给了我以下错误
curl -H Accept:application/json -H Content-Type:application/json -X POST -d '[{"method":"GET","to":"/node/0","id":0}]' http://localhost:7474/db/data/batch
{
"exception" : "NullPointerException",
"fullname" : "java.lang.NullPointerException",
"stacktrace" : [ "org.neo4j.server.web.Jetty9WebServer.invokeDirectly(Jetty9WebServer.java:339)", "org.neo4j.server.rest.batch.NonStreamingBatchOperations.invoke(NonStreamingBatchOperations.java:55)", "org.neo4j.server.rest.batch.BatchOperations.performRequest(BatchOperations.java:201)", "org.neo4j.server.rest.batch.BatchOperations.parseAndPerform(BatchOperations.java:171)", "org.neo4j.server.rest.batch.NonStreamingBatchOperations.performBatchJobs(NonStreamingBatchOperations.java:48)", "org.neo4j.server.rest.web.BatchOperationService.batchProcess(BatchOperationService.java:126)", "org.neo4j.server.rest.web.BatchOperationService.performBatchOperations(BatchOperationService.java:76)", "java.lang.reflect.Method.invoke(Method.java:606)", "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)", "java.lang.Thread.run(Thread.java:744)"]
我看到的唯一日志是http:
127.0.0.1 - - [03 / Jun / 2014:14:56:17 +0200]“POST / db / data / node HTTP / 1.1”201 1160“ - ”“curl / 7.26.0” 127.0.0.1 - - [03 / Jun / 2014:14:56:33 +0200]“GET / db / data / node / 0 HTTP / 1.1”200 1160“ - ”“curl / 7.26.0” 127.0.0.1 - - [03 / Jun / 2014:14:56:47 +0200]“POST / db / data / batch HTTP / 1.1”500 1000“ - ”“curl / 7.26.0”
任何帮助都将不胜感激。
谢谢。
编辑:流模式下的完全相同的请求(即标题X-Stream设置为true)具有不同的行为:它提供预期数据但状态为500.
curl -H X-Stream:true -H Accept:application/json -H Content-Type:application/json -X POST -d '[{"method":"GET","to":"/node/0","id":0}]' http://localhost:7474/db/data/batch
[
{
"id":0,
"from":"/node/0",
"body":
{
"extensions":{},
"paged_traverse":"http://localhost:7474/db/data/node/0/paged/traverse/{returnType}{?pageSize,leaseTime}",
"labels":"http://localhost:7474/db/data/node/0/labels",
"outgoing_relationships":"http://localhost:7474/db/data/node/0/relationships/out",
"traverse":"http://localhost:7474/db/data/node/0/traverse/{returnType}",
"all_typed_relationships":"http://localhost:7474/db/data/node/0/relationships/all/{-list|&|types}",
"property":"http://localhost:7474/db/data/node/0/properties/{key}",
"all_relationships":"http://localhost:7474/db/data/node/0/relationships/all",
"self":"http://localhost:7474/db/data/node/0",
"properties":"http://localhost:7474/db/data/node/0/properties",
"outgoing_typed_relationships":"http://localhost:7474/db/data/node/0/relationships/out/{-list|&|types}",
"incoming_relationships":"http://localhost:7474/db/data/node/0/relationships/in",
"incoming_typed_relationships":"http://localhost:7474/db/data/node/0/relationships/in/{-list|&|types}",
"create_relationship":"http://localhost:7474/db/data/node/0/relationships",
"data":
{
"name":"Steven"
}
},
"status":500
}
]