I need to find a specific node in the entire graph using the Java low level API. I used to do this using the Reference node in versions 1.x but that concept has been removed with the 2.0 release.
I thought I could use labels to do this: I would assign a label to this node (and only this node) when it is created. Subsequently I would get all the nodes with this particular label, which should return a single hit, ie the special node I'm looking for. Unfortunately I can't find a way to look up all nodes having a specific label using the Java API.
I am able to do it with Cypher but I'd like this look up to be as fast as possible, so saving the cost of query parsing, planning and execution would be great.
If you want to get the labels of a specify node, then use labels(node) ; If you only want to get all node labels in neo4j, then use this function instead: call db. labels; , never ever use this query: MATCH n RETURN DISTINCT LABELS(n) .
Following is the query which returns all the nodes in Neo4j database. Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot.
Return all elements When you want to return all nodes, relationships and paths found in a query, you can use the * symbol.
This method GlobalGraphOperations.getAllNodesWithLabel(Label label) returns all nodes with the specified label.
You can use GlobalGraphOperations.at(gdb).getAllRelationshipTypes()
to get all nodes with the label, and gdb
is your graph database.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With