Knowledge graph data management skill
You can use natural language commands to instruct code agents, such as Qoder and CodeX, to manage entity and relationship data in your knowledge graph space. These operations include creating, updating, deleting, and querying entities and relationships individually or in batches; executing Cypher queries; and performing neighbor traversal. This document covers the capability's features, prerequisites, and usage examples, and details the expected results. An appendix lists the required input information.
Features
This capability lets you use natural language commands to manage entity and relationship data in a knowledge graph space. Common operations include creating, updating, deleting, or querying individual entities or relationships, performing a batch import of entities and relationships, running a Cypher query, and traversing the neighbors of a specific entity.
Use cases:
-
Add or maintain entity and relationship data in a knowledge graph space where the ontology model has already been published.
-
Batch import a set of entities or relationships.
-
Query and filter entities and relationships by type, keyword, or property.
-
Explore connections between entities by using Cypher queries or neighbor traversal.
Limitations: Create, Read, Update, and Delete (CRUD) operations on entities and relationships work the same way for both Neo4j and Lindorm graph engines. However, Cypher queries are only available in spaces that use the Neo4j engine. Spaces that use the Lindorm engine do not support Cypher. As an alternative, you can combine entity list queries, neighbor traversal, and semantic searches. Cypher queries can only read data; they cannot be used to write or modify it. As a best practice, delete relationships before deleting their associated entities.
Prerequisites
-
You have a target knowledge graph space with an ontology model (schema) published to the graph engine. This model must define the entity and relationship types you intend to use.
-
You have the space ID for the target knowledge graph space. This ID is not available through self-service and must be obtained from the Knowledge Graph Space List page in the Dataphin console.
-
Before writing an entity or relationship, you must know the primary keys and required properties for the target type.
Examples
The following are sample commands that you can copy and use directly:
-
Create a company entity in the knowledge graph space with the name 'Alibaba Group' and industry 'Internet'.
-
Batch import this set of company entities into the specified knowledge graph space.
-
Create an investment relationship between Company A and Company B with a shareholding ratio of 33%.
-
Query the knowledge graph for company entities in the 'Internet' industry.
-
Use a Cypher query to find which companies Alibaba Group has invested in.
-
View the one-hop neighbors and their relationships for a specific company entity.
Interaction steps:
-
The code agent typically starts by asking you to confirm the target knowledge graph space ID and the entity type or relationship type that you want to work with.
-
Before writing an entity or relationship, the code agent usually gets the list of primary keys and required properties for that type. This practice ensures all necessary information is collected before submission, preventing errors from missing fields.
-
Before it performs write operations such as creating, updating, or deleting an entity or relationship, the code agent asks you to confirm the type code, property values, and the scope of the changes.
-
When deleting data, the agent first deletes the related relationships and then the entity.
-
Before it runs a Cypher query, the code agent verifies that the space's graph engine is Neo4j. It also prompts you to specify type labels for the nodes in the query and set a limit on the number of results to return.
Execution results
After the operation is complete, you receive the following results:
-
Response content: Creating an entity returns an entity ID. A batch creation returns the number of successful and failed operations. Creating a relationship returns a relationship ID. A query returns a list of entities or relationships. A Cypher query returns nodes, edges, or scalar results. A neighbor traversal returns the neighboring nodes and their connecting relationships.
-
Completion status: The status is determined by the success flags and counts returned by the command. For a batch import, the response typically includes both the number of successes and failures.
-
Verification: To verify that the data was written correctly, run an entity or relationship query, or a Cypher query.
A command-line success message only confirms that the platform has accepted your request, not that the operation is complete. Always verify the final outcome in the Dataphin console.
Appendix: Input information
The following table lists information that may be required when managing data in your knowledge graph. This table is for reference only. The code agent automatically identifies the required information from your commands and prompts you if anything is missing. You do not need to provide items marked as not required, as the system generates them automatically.
|
Information |
Required |
Description |
Example |
|
tenant ID |
Conditional |
Optional if already specified in the credential configuration. |
1234567890123456789 |
|
knowledge graph space ID |
Yes |
The ID of the target space. Obtain this from the Knowledge Graph Space List page in the Dataphin console because it is not available through self-service. |
— |
|
entity type code |
Required for entity operations |
Must be predefined in the ontology model. |
COMPANY |
|
relationship type code |
Required for relationship operations |
Must be predefined in the ontology model. |
INVEST |
|
entity or relationship properties |
Required for write operations |
Property codes must match the definitions in the ontology model. You must provide all primary keys and required properties. |
name=Alibaba Group |
|
source and destination entity IDs |
Required for creating relationships |
The entity IDs at both ends of the relationship. |
— |
|
Cypher query |
Required for Cypher queries |
Only available for spaces that use the Neo4j engine. Nodes must include type labels. |
|
|
traversal depth and direction |
No |
Optional for neighbor traversal. Valid directions are |
Depth 1, bidirectional |