Neo4J将节点和标签批量编入索引

时间:2015-07-25 10:21:47

标签: neo4j

我正在尝试批量处理某些节点并将其添加到名为people的索引中。这工作正常但是当我尝试为这些节点中的每一个分配一个标签时,我最终得到下面的堆栈跟踪,这是完全没用的。现在,如果我尝试使用以下URL:/ node,它将工作并分配标签,但我最终得到重复的节点。我试图这样做的主要原因是因为我有一个每晚运行的工作,我有很多数据要批量处理成一个请求,这个数据要求我更新许多节点。我想真正的问题是我可以使用Neo4Js Rest API批量更新节点和关系吗?

我正在使用以下来源玩这个想法 http://neo4j.com/docs/stable/rest-api-batch-ops.html#rest-api-refer-to-items-created-earlier-in-the-same-batch-job http://neo4j.com/docs/stable/rest-api-unique-indexes.html#rest-api-get-or-create-unique-node-create

[
{
    "method": "POST",
    "to": "/index/node/people?uniqueness=get_or_create",
    "id": 0,
    "body": {
        "id": 0,
        "key": "name",
        "value": "Bond",
        "name": "Bond",
        "sequence": 5
    }
},
{
    "method": "POST",
    "to": "/node/{0}/labels",
    "body": "People"
}

{
"message": "",
"exception": "BatchOperationFailedException",
"fullname": "org.neo4j.server.rest.domain.BatchOperationFailedException",
"stackTrace": [
    "org.neo4j.server.rest.batch.NonStreamingBatchOperations.invoke(NonStreamingBatchOperations.java:64)",
    "org.neo4j.server.rest.batch.BatchOperations.performRequest(BatchOperations.java:205)",
    "org.neo4j.server.rest.batch.BatchOperations.parseAndPerform(BatchOperations.java:173)",
    "org.neo4j.server.rest.batch.NonStreamingBatchOperations.performBatchJobs(NonStreamingBatchOperations.java:49)",
    "org.neo4j.server.rest.web.BatchOperationService.batchProcess(BatchOperationService.java:148)",
    "org.neo4j.server.rest.web.BatchOperationService.performBatchOperations(BatchOperationService.java:78)",
    "java.lang.reflect.Method.invoke(Method.java:606)",
    "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)",
    "org.neo4j.server.rest.dbms.AuthorizationFilter.doFilter(AuthorizationFilter.java:120)",
    "java.lang.Thread.run(Thread.java:744)"
],
"errors": [
    {
        "message": "",
        "code": "Neo.DatabaseError.General.UnknownFailure",
        "stackTrace": "org.neo4j.server.rest.domain.BatchOperationFailedException: \n\tat org.neo4j.server.rest.batch.NonStreamingBatchOperations.invoke(NonStreamingBatchOperations.java:64)\n\tat org.neo4j.server.rest.batch.BatchOperations.performRequest(BatchOperations.java:205)\n\tat org.neo4j.server.rest.batch.BatchOperations.parseAndPerform(BatchOperations.java:173)\n\tat org.neo4j.server.rest.batch.NonStreamingBatchOperations.performBatchJobs(NonStreamingBatchOperations.java:49)\n\tat org.neo4j.server.rest.web.BatchOperationService.batchProcess(BatchOperationService.java:148)\n\tat org.neo4j.server.rest.web.BatchOperationService.performBatchOperations(BatchOperationService.java:78)\n\tat sun.reflect.GeneratedMethodAccessor38.invoke(Unknown Source)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:606)\n\tat com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)\n\tat com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)\n\tat com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)\n\tat org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)\n\tat com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)\n\tat com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)\n\tat com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)\n\tat com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)\n\tat com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)\n\tat com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558)\n\tat com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:790)\n\tat org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:800)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)\n\tat org.neo4j.server.rest.dbms.AuthorizationFilter.doFilter(AuthorizationFilter.java:120)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1125)\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1059)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)\n\tat org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)\n\tat org.eclipse.jetty.server.Server.handle(Server.java:497)\n\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)\n\tat org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:248)\n\tat org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:620)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:540)\n\tat java.lang.Thread.run(Thread.java:744)\n"
    }
]

}

0 个答案:

没有答案