updateNode
Update node labels and properties inNeo4jdatabase
Syntax
Description
updateNode(
updates existing node properties with the specified node properties.neo4jconn
,node
,'Properties',properties
)
updateNode(
updates existing node labels and properties.neo4jconn
,node
,'Labels',labels
,'Properties',properties
)
Examples
Update Node Labels
Create a single node in a Neo4j® database and update its node labels.
Create a Neo4j database connection using the URLhttp://localhost:7474/db/data
, user nameneo4j
, and passwordmatlab
.
url ='http://localhost:7474/db/data'; username ='neo4j'; password ='matlab'; neo4jconn = neo4j(url,username,password);
Check theMessage
property of the Neo4j connection objectneo4jconn
. The blankMessage
property indicates a successful connection.
neo4jconn.Message
ans = []
Create a single node in the database using the Neo4j database connection.
node = createNode(neo4jconn)
node = Neo4jNode with properties: NodeID: 47 NodeData: [1×1 struct] NodeLabels: []
node
is aNeo4jNode
object with these properties:
Node identifier
Node data
Node label
Update the node by adding the labelsPerson
andEmployee
.
labels = ["Person","Employee"]; updateNode(neo4jconn,node,'Labels',labels)
Display the updated node information.nodeinfo
is aNeo4jNode
object.
nodeid = node.NodeID; nodeinfo = searchNodeByID(neo4jconn,nodeid); nodeinfo.NodeLabels
ans =2×1 cell array{'Person' } {'Employee'}
Close the database connection.
close(neo4jconn)
Update Properties of Existing Node
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 keyname
with a value ranging fromUser1
throughUser7
. Each relationship has the typeknows
.
Create a Neo4j database connection using the URLhttp://localhost:7474/db/data
, user nameneo4j
, and passwordmatlab
.
url ='http://localhost:7474/db/data'; username ='neo4j'; password ='matlab'; neo4jconn = neo4j(url,username,password);
Check theMessage
property of the Neo4j connection objectneo4jconn
. The blankMessage
property indicates a successful connection.
neo4jconn.Message
ans = []
Search for a node with the labelPerson
. Then, using the Neo4j database connection, filter the results by the property key and value for the person namedUser7
.
nlabel ='Person'; node = searchNode(neo4jconn,nlabel,'PropertyKey','name',...'PropertyValue','User7')
node = Neo4jNode with properties: NodeID: 9 NodeData: [1×1 struct] NodeLabels: 'Person'
node
is aNeo4jNode
object with these properties:
Node identifier
Node data
Node labels
Retrieve the existing properties of the node by using theNodeData
property of theNeo4jNode
object.properties
is a structure.
properties = node.NodeData
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.
properties.title ='Analyst'; updateNode(neo4jconn,node,'Properties',properties)
显示更新后的节点支撑erties.nodeinfo
is aNeo4jNode
object.
nodeid = node.NodeID; nodeinfo = searchNodeByID(neo4jconn,nodeid); nodeinfo.NodeData
ans =struct with fields:name: 'User7' title: 'Analyst'
Close the database connection.
close(neo4jconn)
Update Labels and Properties for One Node
创建一个节点在一个Neo4j®数据库,更新its node labels and properties, and display them.
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 keyname
with a value ranging fromUser1
throughUser7
. Each relationship has the typeknows
.
Create a Neo4j database connection using the URLhttp://localhost:7474/db/data
, user nameneo4j
, and passwordmatlab
.
url ='http://localhost:7474/db/data'; username ='neo4j'; password ='matlab'; neo4jconn = neo4j(url,username,password);
Check theMessage
property of the Neo4j connection objectneo4jconn
. The blankMessage
property indicates a successful connection.
neo4jconn.Message
ans = []
Create a single node in the database using the Neo4j database connection.
node = createNode(neo4jconn)
node = Neo4jNode with properties: NodeID: 48 NodeData: [1×1 struct] NodeLabels: []
node
is aNeo4jNode
object with these properties:
Node identifier
Node data
Node labels
Create a table with one row that contains data about a person. Specify the name and job title of the person.
properties = table("User8","Analyst",'VariableNames',{'Name','Title'});
Update the node by adding the labelsPerson
andEmployee
and the node properties defined in the table.
labels = ["Person","Employee"]; updateNode(neo4jconn,node,'Labels',labels,...'Properties',properties)
Display the updated node labels.nodeinfo
is aNeo4jNode
object.
nodeid = node.NodeID; nodeinfo = searchNodeByID(neo4jconn,nodeid); nodeinfo.NodeLabels
ans =2×1 cell array{'Person' } {'Employee'}
显示更新后的节点支撑erties.
nodeinfo.NodeData
ans =struct with fields:Title: 'Analyst' Name: 'User8'
Close the database connection.
close(neo4jconn)
Update Labels and Properties for Two Nodes
Create two nodes in a Neo4j® database, update their node labels and properties, and display the labels and properties for the first node.
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 keyname
with a value ranging fromUser1
throughUser7
. Each relationship has the typeknows
.
Create a Neo4j database connection using the URLhttp://localhost:7474/db/data
, user nameneo4j
, and passwordmatlab
.
url ='http://localhost:7474/db/data'; username ='neo4j'; password ='matlab'; neo4jconn = neo4j(url,username,password);
Check theMessage
property of the Neo4j connection objectneo4jconn
. The blankMessage
property indicates a successful connection.
neo4jconn.Message
ans = []
Create two nodes in the database using the Neo4j database connection. These nodes represent two people.
user8 = createNode(neo4jconn); user9 = createNode(neo4jconn);
Create a table with two rows. Each row contains data about a person. Specify the name and job title for each person.
properties = table(["User8";"User9"],["Analyst";"Technician"],...'VariableNames',{'Name','Title'});
Update the nodes by adding the labelsPerson
andEmployee
and the node properties defined in the table.
labels = ["Person","Employee"]; updateNode(neo4jconn,[user8;user9],'Labels',labels,...'Properties',properties)
Display the node labels for the nodes.
nodeid = [user8.NodeID user9.NodeID]; nodeinfo = searchNodeByID(neo4jconn,nodeid); nodeinfo.NodeLabels{:}
ans =2×1 cell array{'Person' } {'Employee'}
ans =2×1 cell array{'Person' } {'Employee'}
Display the node properties for the nodes.
nodeinfo.NodeData{:}
ans =struct with fields:Title: 'Analyst' Name: 'User8'
ans =struct with fields:Title: 'Technician' Name: 'User9'
Close the database connection.
close(neo4jconn)
Update Node Properties and Return Output
创建一个节点在一个Neo4j®数据库,更新its properties, and display them. Access the updated node information using an output argument.
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 keyname
with a value ranging fromUser1
throughUser7
. Each relationship has the typeknows
.
Create a Neo4j database connection using the URLhttp://localhost:7474/db/data
, user nameneo4j
, and passwordmatlab
.
url ='http://localhost:7474/db/data'; username ='neo4j'; password ='matlab'; neo4jconn = neo4j(url,username,password);
Check theMessage
property of the Neo4j connection objectneo4jconn
. The blankMessage
property indicates a successful connection.
neo4jconn.Message
ans = []
Create a single node in the database using the Neo4j database connection.
node = createNode(neo4jconn)
node = Neo4jNode with properties: NodeID: 49 NodeData: [1×1 struct] NodeLabels: []
node
is aNeo4jNode
object with these properties:
Node identifier
Node data
Node labels
Update the properties of a node that represents a person. Create a table with one row that contains the name and job title for this person. Thenodeinfo
output argument is aNeo4jNode
object.
properties = table("User8","Analyst",'VariableNames',{'Name','Title'}); nodeinfo = updateNode(neo4jconn,node,'Properties',properties);
Display the node properties.
nodeinfo.NodeData
ans =struct with fields:Title: 'Analyst' Name: 'User8'
Close the database connection.
close(neo4jconn)
Input Arguments
neo4jconn
—Neo4j database connection
Neo4jConnect
object
Neo4j database connection, specified as aNeo4jConnect
object created with the functionneo4j
.
node
—Node
Neo4jNode
object|Neo4jNode
object array|numeric scalar|numeric vector
Node in a Neo4j database, specified as aNeo4jNode
object,Neo4jNode
object array, numeric scalar, or a numeric vector. For one node, specify aNeo4jNode
object or a numeric scalar. For multiple nodes, specify aNeo4jNode
object array or a numeric vector.
The numeric scalar or vector must contain Neo4j database node identifiers.
Example:15
Example:[2,3,4]
labels
—Node labels
character vector|cell array of character vectors|string scalar|string array|cell array of cell arrays|cell array of string arrays
Node labels, specified as a character vector, cell array of character vectors, string scalar, string array, cell array of cell arrays, or cell array of string arrays. To specify one node label, use a character vector or string scalar. For multiple node labels, use a cell array of character vectors or a string array. To update multiple nodes with different node labels, use a cell array of cell arrays or a cell array of string arrays.
Example:'Person'
Data Types:char
|string
|cell
properties
—Node properties
structure|structure array|table|cell array of structures
Node properties, specified as a structure, structure array, table, or cell array of structures.
When you specify a structure, theupdateNode
function converts each field and its corresponding value to a property and its corresponding value in the database node. The function also sets theNodeData
property of theNeo4jNode
object to this structure.
When you specify a table that contains one row, theupdateNode
函数将每个变量及其对应ing value to a property and its corresponding value in the database node. The function also converts the variables and their corresponding values to fields and their corresponding values in a structure. The function sets this structure to theNodeData
property of theNeo4jNode
object.
To update multiple nodes, specify a structure array or table with multiple rows.
To update multiple nodes with different properties, specify a cell array of structures.
Note
If a property is missing its corresponding value, then the updated node does not contain this property.
Data Types:struct
|table
|cell
Output Arguments
nodeinfo
— Node information
Neo4jNode
object | table
Node information in the Neo4j database, returned as aNeo4jNode
object for one node or as a table for multiple nodes.
For multiple nodes, the table contains these variables:
NodeLabels
— Cell array of character vectors that contains the node labels for each database nodeNodeData
— Cell array of structures that contains node information such as property keysNodeObject
—Neo4jNode
object for each database node
The row names of the table are Neo4j node identifiers of each database node.
Version History
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina(Español)
- Canada(English)
- United States(English)
Europe
- Belgium(English)
- Denmark(English)
- Deutschland(Deutsch)
- España(Español)
- Finland(English)
- France(Français)
- Ireland(English)
- Italia(Italiano)
- Luxembourg(English)
- Netherlands(English)
- Norway(English)
- Österreich(Deutsch)
- Portugal(English)
- Sweden(English)
- Switzerland
- United Kingdom(English)