Main Content


Search Neo4j database nodes by node identifier



nodeinfo = searchNodeByID(neo4jconn,nodeid) creates the Neo4jNode object using the Neo4j® database connection neo4jconn and the node identifier nodeid.


collapse all

Create a Neo4j® database connection using the URL http://localhost:7474/db/data, user name neo4j, and password matlab.

url = 'http://localhost:7474/db/data';
username = 'neo4j';
password = 'matlab';

neo4jconn = neo4j(url,username,password);

Check the Message property of the Neo4j connection object neo4jconn. The blank Message property indicates a successful connection.

ans =


Search the database for the node with the node identifier 2 by using the Neo4j database connection neo4jconn.

nodeid = 2;

nodeinfo = searchNodeByID(neo4jconn,nodeid)
nodeinfo = 
  Neo4jNode with properties:

        NodeID: 2
      NodeData: [1×1 struct]
    NodeLabels: 'Person'

nodeinfo is a Neo4jNode object with these properties:

  • Node identifier

  • Node data

  • Node labels

Access the property keys and values of the node using the property NodeData.

ans = struct with fields:
    name: 'User2'

Close the database connection.


Input Arguments

collapse all

Neo4j database connection, specified as a Neo4jConnect object created with the function neo4j.

Node identifier of a Neo4j database node, specified as a numeric scalar for one node in the Neo4j database, or a numeric vector for multiple nodes. If a node identifier is unknown, search for nodes using searchNode and search for relationships using searchRelation.

Data Types: double

Output Arguments

collapse all

Node information for one node in the Neo4j database, returned as a Neo4jNode object. You can use this node as the origin node for searching the Neo4j database.

Version History

Introduced in R2016b