4

I looked at how I can easily get a Node by ID through cypher, yet the methods that are available for the Node interface do not appear to support a way to return a particular Node object based on ID.

How can I return a particular node by ID with the Neo4j embedded Java library? Same question with relationships...

Community
  • 1
  • 1
WildBill
  • 9,143
  • 15
  • 63
  • 87
  • Prefer this question be opened back up. This is a very specific question within the Neo4J embedded Java framework. Looking at the documents for the Node interface, I do not see a way to return a Node object based on ID. That was my question. This is either a very simple and specific answer or there is no straight forward way to do what is otherwise easy to do in Cypher (the neo4j query language) – WildBill Mar 11 '15 at 15:00
  • 4
    It seems that almost all of the people who voted to close have never asked/answered a neo4j question. This question is indeed very focused. Anway, the anwers are: you use [GraphDatabaseService.getNodeById](http://neo4j.com/api_docs/2.0.0/org/neo4j/graphdb/GraphDatabaseService.html#getNodeById(long)) and [GraphDatabaseService.getRelationshipById](http://neo4j.com/api_docs/2.0.0/org/neo4j/graphdb/GraphDatabaseService.html#getRelationshipById(long)) – cybersam Mar 13 '15 at 15:45
  • OMG thank you so much! I hadn't come across that interface in the docs yet, didn't seem like the natural place for such a method. – WildBill Mar 13 '15 at 18:35
  • Hopefully they open the question back up and you can answer and get points. Agree, putting this on hold was a bit short-sighted and folks likely didn't realize that Nodes are a specific object type within the Neo4j framework. – WildBill Mar 13 '15 at 18:36

1 Answers1

3

You use GraphDatabaseService.getNodeById and GraphDatabaseService.getRelationshipById.

cybersam
  • 63,203
  • 6
  • 53
  • 76