Cypher API
The Cypher API for Aura Graph Analytics matches the GDS plugin API as closely as possible. Except for some limitations, you can adapt most of the examples from the rest of the documentation.
|
You can now use the Cypher API inside an AuraDB without Aura API credentials. |
Projecting a graph
Cypher projections
Use a Cypher projection with the additional authentication clause to project a graph into a GDS Session.
Make sure to include the additional parameters with the Aura Graph Analytics label to create a session at the same time.
CYPHER runtime=parallel (1)
MATCH (source)
OPTIONAL MATCH (source)-->(target)
RETURN gds.graph.project('g',
source,
target,
{},
{ memory: '2GB' } (2)
)
| 1 | The Cypher parallel runtime is recommended but not mandatory. |
| 2 | Map containing session-related parameters such as memory (mandatory). |
If you have created a session explicitly, add the session ID as the sessionId parameter to use that session instead.
CYPHER runtime=parallel (1)
MATCH (source)
OPTIONAL MATCH (source)-->(target)
RETURN gds.graph.project('g',
source,
target,
{},
{ sessionId: '00000000-11111111' }
)
| 1 | The Cypher parallel runtime is recommended but not mandatory. |
Native projections
Aura Graph Analytics supports xref:management-ops/graph-creation/graph-project.adoc[native projections] with a limited feature set.
CALL gds.graph.project(
graphName: String,
nodeLabels: String or List,
relationshipTypes: String or List,
configuration: Map
) YIELD
graphName: String,
nodeProjection: Map,
nodeCount: Integer,
relationshipProjection: Map,
relationshipCount: Integer,
projectMillis: Integer
| Name | Type | Optional | Description |
|---|---|---|---|
graphName |
String |
no |
The name under which the graph is stored in the catalog. |
nodeLabels |
String, List |
no |
One or more node labels to include in the projection. Can be |
relationshipTypes |
String, List |
no |
One or more relationship types to include in the projection. Can be |
configuration |
Map |
no |
Additional parameters to configure the native projection. |
| Name | Type | Default | Optional | Description |
|---|---|---|---|---|
nodeProperties |
String, List |
{} |
yes |
The node properties to load from nodes that match any of the labels specified in |
relationshipProperties |
String, List |
{} |
yes |
The relationship properties to load from relationships that match any of the types specified in |
undirectedRelationshipTypes |
List |
[] |
yes |
The relationship types that should be projected as undirected. |
inverseIndexedRelationshipTypes |
List |
[] |
yes |
The relationship types for which an inverse index wil be generated. |
readConcurrency |
Integer |
All available cores |
yes |
The number of concurrent threads used for creating the graph. |
batchSize |
Integer |
16000 |
yes |
The size of each batch of data send to the session. |
jobId |
String |
Generated internally |
yes |
An ID that can be provided to more easily track the projection’s progress. |
sessionId |
String |
null |
yes |
The session in which the graph will be projected. |
memory |
String |
null |
yes |
The size of the GDS Session, e.g. |
ttl |
Duration |
1h |
yes |
The time to live of the GDS Session when no activity is recorded, e.g. |
| Name | Type | Description |
|---|---|---|
graphName |
String |
The name under which the graph is stored in the catalog. |
nodeProjection |
Map |
The node projections used to project the graph. |
nodeCount |
Integer |
The number of nodes stored in the projected graph. |
relationshipProjection |
Map |
The relationship projections used to project the graph. |
relationshipCount |
Integer |
The number of relationships stored in the projected graph. |
projectMillis |
Integer |
Milliseconds for projecting the graph. |
The following query will create a new session and project the graph into it.
In this case the memory parameter is required to determine the size of the newly created session.
CALL gds.graph.project(
'g',
'*',
'*',
{
memory: '2GB'
}
) YIELD nodeCount, relationshipCount, projectMillis
If you have created a session explicitly, add the session ID as the sessionId parameter to use that session instead.
CALL gds.graph.project(
'g',
'*',
'*',
{
sessionId: '00000000-11111111'
}
) YIELD nodeCount, relationshipCount, projectMillis
Running algorithms
|
See the Limitations section for the list of unsupported algorithms. |
The Cypher API for Aura Graph Analytics supports most algorithms and machine learning operations in all existing execution modes. The syntax is the same as for the GDS plugin, with the additional authentication clause.
stream modeCALL gds.pageRank.stream('g')
Session management
The session management procedures allow to explicitly create new sessions without any attached graphs, or to list and delete existing sessions.
Creating sessions
Calling the gds.session.getOrCreate procedure triggers the creation of a GDS Session based on the specified procedure parameters.
If a session with the given name and configuration already exists, that session is returned instead.
CALL gds.session.getOrCreate(
'test-session',
'2GB',
duration({minutes: 30})
)
YIELD name
RETURN name
| name |
|---|
"test-session" |
When you create a session explicitly with gds.session.getOrCreate, note down the sessionId and set it as a configuration parameter for the gds.graph.project procedure when you project a new graph.
Syntax
CALL gds.session.getOrCreate(
sessionName: String,
memory: String,
ttl: Duration
cloudLocation: Map
) YIELD
id: String,
name: String,
auraInstanceId: String,
memory: String,
status: String,
creationTime: Datetime,
host: String,
expiryDate: Datetime,
ttl: TemporalAmount,
errorMessage: String
| Name | Type | Optional | Description |
|---|---|---|---|
sessionName |
String |
no |
The name of the GDS Session to create or return. |
memory |
String |
no |
The size of the GDS Session, e.g. |
ttl |
Duration |
yes |
The time to live of the GDS Session when no activity is recorded, e.g. |
| Name | Type | Description |
|---|---|---|
|
String |
The unique identifier of the GDS Session. |
|
String |
The name of the GDS Session. |
|
String |
The Aura instance ID to which the GDS Session is attached to. |
|
String |
The size of the GDS Session, e.g. |
|
String |
The status of the GDS Session, e.g. |
|
Datetime |
The time when the GDS Session was created. |
|
String |
The public host address of the GDS Session. |
|
Datetime |
The time when the GDS Session will definitely expire. |
|
TemporalAmount |
The time that is left until the GDS Session expires due to inactivity. |
|
String |
The error message, if the GDS Session could not be created or is in an unhealthy state. |
Listing sessions
The gds.session.list procedure returns all the GDS Sessions that are available to the current Aura user.
Syntax
CALL gds.session.list(
projectId: String,
filterAuraInstanceId: boolean
) YIELD
id: String,
name: String,
auraInstanceId: String,
memory: String,
status: String,
creationTime: Datetime,
host: String,
expiryDate: Datetime,
ttl: TemporalAmount,
errorMessage: String
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
projectId |
String |
yes |
"" |
The ID of the project to which the GDS Sessions belong. If not specified, all sessions of the Aura user are returned. |
filterAuraInstance |
String |
yes |
false |
If set to |
| Name | Type | Description |
|---|---|---|
|
String |
The unique identifier of the GDS Session. |
|
String |
The name of the GDS Session. |
|
String |
The Aura instance ID to which the GDS Session is attached to. |
|
String |
The size of the GDS Session, e.g. |
|
String |
The status of the GDS Session, e.g. |
|
Datetime |
The time when the GDS Session was created. |
|
String |
The public host address of the GDS Session. |
|
Datetime |
The time when the GDS Session will definitely expire. |
|
TemporalAmount |
The time that is left until the GDS Session expires due to inactivity. |
|
String |
The error message, if the GDS Session could not be created or is in an unhealthy state. |
Deleting sessions
The gds.session.delete procedure deletes a GDS Session with the given sessionName.
If the session is not found, an error is raised.
CALL gds.session.delete(
'test-session'
)
YIELD deleted
RETURN deleted
| deleted |
|---|
true |
Syntax
CALL gds.session.delete(
name: String,
projectId: String
) YIELD
deleted: boolean
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
name |
String |
no |
n/a |
The name of the GDS Session to delete. |
projectId |
String |
yes |
"" |
The ID of the project to which the GDS Session belongs. If similar sessions exist in different projects an error is thrown that indicates to provide a project ID. |
| Name | Type | Description |
|---|---|---|
deleted |
Boolean |
True, if the GDS Session was successfully deleted, false otherwise. |
Retrieving session information for a graph
The gds.graph.sessionInfo function returns information about the GDS Session that is associated with a projected graph.
It can be used to retrieve information required for the sessionName parameter of most gds.model procedures.
Syntax
RETURN gds.graph.sessionInfo(graphName: String): Map
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
graphName |
String |
no |
n/a |
The name of the graph for which the GDS Session information will be returned. |
Returns a Map value with two entries:
| Name | Type | Description |
|---|---|---|
|
String |
The name of the GDS Session the graph is projected in. |
|
String |
The id of the GDS Session the graph is projected in. |
Estimating session size
The gds.session.estimate procedure estimates the memory required for a GDS Session based on the size and shape of your graph.
Use it to determine an appropriate session size before creating a session.
Syntax
CALL gds.session.estimate(
nodeCount: Integer,
relationshipCount: Integer,
configuration: Map
) YIELD
estimatedMemory: String,
recommendedSize: String
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
nodeCount |
Integer |
no |
n/a |
The number of nodes in the graph. |
relationshipCount |
Integer |
no |
n/a |
The number of relationships in the graph. |
configuration |
Map |
yes |
{} |
Optional configuration map. See the configuration keys below. |
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
nodeLabelCount |
Integer |
yes |
0 |
The number of distinct node labels in the graph. |
nodePropertyCount |
Integer |
yes |
0 |
The number of node properties in the graph. |
relationshipPropertyCount |
Integer |
yes |
0 |
The number of relationship properties in the graph. |
algorithmCategories |
List of String |
yes |
[] |
The categories of algorithms you plan to run in the session. Providing this helps produce a more tailored estimate. See the valid values below. |
The following values are accepted for algorithmCategories (case-insensitive; hyphens and underscores are interchangeable):
-
centrality -
community-detection -
similarity -
path-finding -
node-embedding -
machine-learning
| Name | Type | Description |
|---|---|---|
|
String |
The estimated memory required for the session, e.g. |
|
String |
The recommended session size to request, e.g. |
Limitations
When compared to the GDS plugin, the Cypher API for Aura Graph Analytics has some limitations.
|
If you use Aura Graph Analytics via the GDS Python client, some of these limitations might not apply. See the Python client docs for more information. |
Other procedures and functions
The Cypher API for Aura Graph Analytics does not support all procedures and functions available in the GDS plugin. Some that are mentioned here may be supported in the future, while others may never be supported.
Graph catalog
The following graph catalog procedures are not supported:
-
gds.graph.project -
gds.graph.project.estimate -
gds.graph.project.cypher -
gds.graph.project.cypher.estimate -
gds.graph.export -
gds.graph.export.csv -
gds.graph.export.csv.estimate -
gds.backup -
gds.restore
Machine learning
Trained models can only be used for prediction using the same session in which they were trained. After the session is deleted, all trained models will be lost.
The following Machine Learning procedures are not supported:
-
gds.model.publish -
gds.linkprediction.adamicAdar -
gds.linkprediction.commonNeighbors -
gds.linkprediction.preferentialAttachment -
gds.linkprediction.resourceAllocation -
gds.linkprediction.sameCommunity -
gds.linkprediction.totalNeighbors -
gds.splitRelationships
Explicit authentication to the Aura API
When executing Cypher queries directly within an AuraDB instance, you are automatically authorized to create and manage your own Aura Graph Analytics sessions, and you do not need to provide explicit API credentials.
Explicit authentication via Aura API credentials is required in only two specific scenarios:
-
Project-wide administration (Cypher): You are using Cypher and need to manage lifecycle operations (such as listing or deleting) for all sessions within the broader Aura Console Project, rather than just the sessions created by your specific logged-in database user. In this case, you must use the
gds.aura.api.credentials()function in each Cypher query. -
Using the Python client: If you are orchestrating sessions using the dedicated GDS Python library, the client requires Aura API credentials to authenticate with the control plane. For instructions, see the Neo4j Graph Data Science Client documentation.
|
It is good practice to use query parameters for sensitive data such as credentials. This also removes the need to enter the same strings multiple times. In the Aura console, you can set query parameters within the Query tool. For other environments, see the Cypher manual. |
gds.aura.api.credentialsWITH gds.aura.api.credentials($clientId, $clientSecret) AS credentials (1)
MATCH (source)
OPTIONAL MATCH (source)-->(target)
RETURN gds.graph.project('g',
source,
target,
{},
{ memory: '4GB' }
)
| 1 | You can use any alias, provided that you specify one. |
The function does not return any value, but registers the credentials in the query context. The credentials are not persisted anywhere and are immediately discarded after the query has completed.
If you are operating in this admin context, you must include the credentials function in every query that interacts with the session. For example, if you created a graph using explicit credentials, attempting to run an algorithm in a new query without passing them again will fail.
CALL gds.wcc.stream('g') // This alone will not work
Syntax
RETURN gds.aura.api.credentials(
clientId: String,
clientSecret: String
) AS credentials
| Name | Type | Default | Optional | Description |
|---|---|---|---|---|
clientId |
String |
|
no |
The Client ID for an Aura API key pair. |
clientSecret |
String |
|
no |
The Client Secret for an Aura API key pair. |
| Name | Type | Description |
|---|---|---|
- |
- |
Always returns |