Search for an existing node in a Neo4j® database, add a node property, and display the updated node properties.
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 a node with the label Person
. Then, using the Neo4j database connection, filter the results by the property key and value for the person named User7
.
node =
Neo4jNode with properties:
NodeID: 9
NodeData: [1×1 struct]
NodeLabels: 'Person'
node
is a Neo4jNode
object with these properties:
Node identifier
Node data
Node labels
Retrieve the existing properties of the node by using the NodeData
property of the Neo4jNode
object. properties
is a structure.
properties = struct with fields:
name: 'User7'
Update the properties of the node. Add another node property by setting a new field in the structure to specify the job title of the person.
Display the updated node properties. nodeinfo
is a Neo4jNode
object.
ans = struct with fields:
name: 'User7'
title: 'Analyst'
Close the database connection.