The open graph is schema-free, requiring no explicit schema definitions before data insertion. You can directly insert nodes and edges into the graph, and their labels and properties are created on the fly. This offers maximum flexibility for early-stage data exploration.
In an open graph:
NOTEEach graph can only be typed or open. The mode cannot be changed after creation.
To create an open graph g1:
GQLCREATE GRAPH g1 ANY
The ANY keyword identifies an open graph.
GQLMATCH (n:Person {_id: 'p1'}) SET n:VIP MATCH (n {_id: 'p1'}) SET n:Experienced, n:Veteran
Adding labels to edges:
GQLMATCH ()-[r {note: 'test'}]->() SET r:NEW_TYPE
GQLMATCH (n {_id: 'p3'}) REMOVE n:Employee MATCH (n {_id: 'p4'}) REMOVE n:Person, n:Manager
Removing labels from edges:
GQLMATCH ()-[r {since: 2021}]->() REMOVE r:WORKS_WITH
To show labels in the current graph:
GQLSHOW LABELS
To show node labels in the current graph:
GQLSHOW NODE LABEL
To show edge labels in the current graph:
GQLSHOW EDGE LABEL
Each label provides the following essential metadata:
Field | Description |
|---|---|
label_name | The name of the label. |
label_id | The ID of the label. |
You can create new labels within an open graph.
To create a node label User within the current graph:
GQLCREATE NODE LABEL User
To create an edge label Transfers within the current graph:
GQLCREATE EDGE LABEL Transfers
You can delete labels from a graph. Deleting a label will not remove the nodes or edges that use it.
To drop the node label Person from the current graph:
GQLDROP NODE LABEL Person
To drop the edge label LINKS from the current graph:
GQLDROP EDGE LABEL LINKS
In an open graph, properties are fully dynamic:
GQLINSERT (:Person {_id: 'p1', name: 'Alice', age: 30, hobbies: 'reading', score: 95.5}) INSERT (:Person {_id: 'p2', name: 'Bob', department: 'IT'})
Different entities can have different property sets. Use property_exists() to check for a property:
GQLMATCH (n {_id: 'p1'}) RETURN property_exists(n, name)
ALTER GRAPH ... ADD/DROP NODE/EDGE, ALTER NODE/EDGE ... ADD/DROP/RENAME PROPERTY, CREATE INDEX, CREATE FULLTEXT, CREATE TRIGGER).insertNodesBatchBySchema / insertEdgesBatchBySchema) is not available for open graphs.