Search for a single relationship or multiple relationships by using relationship identifiers in the Neo4j® database.
Assume that you have graph data stored in a Neo4j database that represents a social neighborhood. This database has seven nodes and eight relationships. Each node has only one unique property key name with a value ranging from User1 through User7. Each relationship has the type knows.
Create a Neo4j database connection using the URL http://localhost:7474/db/data, user name neo4j, and password matlab.
Check the Message property of the Neo4j connection object neo4jconn. The blank Message property indicates a successful connection.
Search for the relationship with the identifier 8 by using the Neo4j database connection.
relationinfo =
Neo4jRelation with properties:
RelationID: 8
RelationData: [1×1 struct]
StartNodeID: 5
RelationType: 'knows'
EndNodeID: 9
relationinfo is a Neo4jRelation object with these properties:
Relationship identifier
Relationship data
Start node identifier
Relationship type
End node identifier
Display the relationship type.
Search for multiple relationships with the identifiers 4, 5, and 6 by using the Neo4j database connection.
relationinfo=3×5 table
StartNodeID RelationType EndNodeID RelationData RelationObject
___________ ____________ _________ ____________ _______________________________________
5 3 'knows' 4 [1×1 struct] [1x1 database.neo4j.http.Neo4jRelation]
4 3 'knows' 5 [1×1 struct] [1x1 database.neo4j.http.Neo4jRelation]
6 5 'knows' 4 [1×1 struct] [1x1 database.neo4j.http.Neo4jRelation]
relationinfo is a table with these variables:
Start node identifier
Relationship type
End node identifier
Relationship data
Neo4jRelation object
Close the database connection.