0
votes

I have an existing database with Node labeled as “Person” and posting this bulk insert works (e.g., nodes appear with properties), but does not label the node as a "Person"

[{"method":"POST","to":"/node","body":{"RN":"2","fullname":"Herman Allen Slumpff","surname":"Slumpff", 
"name":"Herman Allen","sex":"M","union_id":"309","mn":"1","bd":"19161207","dd":"19901127", 
"bp_id":"56","dp_id":"4441"},"ID":0}]

In fact, I can iterate many nodes and quickly insert them with this method. But, they are unlabeled notes.

The Neo4j documentation suggests the request below should work, but it does not:

[{"method":"POST","to":"/node","body":{"RN":"2","fullname":"Herman Allen Slumpff", 
"surname":"Slumpff","name":"Herman Allen","sex":"M","union_id":"309","mn":"1","bd":"19161207","dd":"19901127", 
"bp_id":"56","dp_id":"4441","ID":0},{"method":"POST","to":"{0}/labels","body":"Person"}]

I am using Neo4j 2.1.6. Perhaps there is a versioning issue?

WebException Error: The remote server returned an error: (500) Internal Server Error.

7

{
  "message" : "Unexpected character ('{' (code 123)): was expecting double-quote to start field name\n  
  at [Source: org.eclipse.jetty.server.HttpConnection$Input@1ffc119{HttpChannelOverHttp@1de8fe8 
  {r=2,a=DISPATCHED,uri=/db/data/batch},HttpConnection@b9f35c{FILLING},g=HttpGenerator{s=START}, 
   p=HttpParser{s=END,280 of 280}}; line: 1, column: 230]",
  "exception" : "JsonParseException",
  "fullname" : "org.codehaus.jackson.JsonParseException",
  "stacktrace" : [ "org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1433)", 
  "org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:521)", 
  "org.codehaus.jackson.impl.JsonParserMinimalBase._reportUnexpectedChar(JsonParserMinimalBase.java:442)",   
  "org.codehaus.jackson.impl.Utf8StreamParser._handleUnusualFieldName(Utf8StreamParser.java:1537)",   
  "org.codehaus.jackson.impl.Utf8StreamParser._parseFieldName(Utf8StreamParser.java:1227)",   
  "org.codehaus.jackson.impl.Utf8StreamParser.nextToken(Utf8StreamParser.java:495)", 
  "org.neo4j.server.rest.batch.BatchOperations.parseAndPerform(BatchOperations.java:152)", 
  "org.neo4j.server.rest.batch.NonStreamingBatchOperations.performBatchJobs(NonStreamingBatchOperations.java:49)", 
  "org.neo4j.server.rest.web.BatchOperationService.batchProcess(BatchOperationService.java:128)", 
  "org.neo4j.server.rest.web.BatchOperationService.performBatchOperations(BatchOperationService.java:77)", 
  "java.lang.reflect.Method.invoke(Unknown Source)", 
  "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)", 
  "java.lang.Thread.run(Unknown Source)" ]
}

Thanks!

Dave

1
I have resolved this issue. I first bulk insert the nodes, then query for them. Then, I iterate thru the nodes, determining their type by their properties and assign the label accordingly using the verb /node/{0}/labels.David A Stumpf

1 Answers

0
votes

You probably accidentally moved your "id":0 from outside of the node-property-body to inside the node property body? Then the {0} can't refer to the job-id 0 anymore.

[{"method":"POST","to":"/node",
  "body":{"RN":"2","fullname":"Herman Allen Slumpff","surname":"Slumpff","name":"Herman Allen", 
  "sex":"M","union_id":"309","mn":"1","bd":"19161207","dd":"19901127","bp_id":"56","dp_id":"4441"},
  "id":0},
 {"method":"POST","to":"{0}/labels","body":"Person"}]

Please try that just to be sure.