UltipaDocs
Try Playground
  • Introduction
    • Overview
    • Node and Edge Patterns
    • Path Patterns
    • Quantified Paths
    • Shortest Paths
    • Graph Patterns
    • Overview
    • Typed Graph
    • Open Graph
    • Graph Sharding and Storage
    • Constraints
    • Unique Identifiers
    • INSERT
    • INSERT OVERWRITE
    • UPSERT
    • SET
    • REMOVE
    • DELETE
    • Query Composition
    • Result Table and Visualization
    • MATCH
    • OPTIONAL MATCH
    • FILTER
    • LET
    • FOR
    • ORDER BY
    • LIMIT
    • SKIP
    • CALL
    • RETURN
    • Composite Query
    • NEXT
    • All Functions
    • Scalar Functions
    • Path Functions
    • Aggregate Functions
    • Mathematical Functions
    • Trigonometric Functions
    • String Functions
    • List Functions
    • Datetime Functions
    • Spatial Functions
    • Table Functions
  • Operators
  • Predicates
  • Expressions
    • Index
    • Full-text Index
    • Vector Index
    • Managing HDC Graphs
    • HDC Graph Queries
  • Transaction
  • Trigger
    • Process
    • Job
    • Execution Plan
    • Variables
    • Values and Types
    • Comments
    • Reserved Words
    • Syntactic Notation
  • Access Control
  • GQL Conformance
  1. Docs
  2. /
  3. ISO GQL
  4. /
  5. HDC Graphs

HDC Graph Queries

Overview

To execute a query on an HDC graph, use the syntax:

Syntax
EXEC{
  <query>
} ON <hdcGraphName>

HDC graphs support queries that retrieve data from the database with enhanced efficiency, but do not allow operations that modify the graph structure or data.

Example Graph

Run the following statements on an empty graph to define its structure and insert data:

GQL
ALTER GRAPH CURRENT_GRAPH ADD NODE {
  entity ()
};
ALTER GRAPH CURRENT_GRAPH ADD EDGE {
  link ()-[{weight float}]->()
};
INSERT (A:entity {_id: "A"}),
       (B:entity {_id: "B"}),
       (C:entity {_id: "C"}),
       (D:entity {_id: "D"}),
       (A)-[:link {weight: 1}]->(B),
       (A)-[:link {weight: 1.5}]->(C),
       (A)-[:link {weight: 0.5}]->(D),
       (B)-[:link {weight: 2}]->(C),
       (C)-[:link {weight: 0.5}]->(D);

Queries on HDC Graphs

To create an HDC graph hdcGraph of the entire graph:

GQL
CREATE HDC GRAPH hdcGraph ON "hdc-server-1" OPTIONS {
  nodes: {"*": ["*"]},
  edges: {"*": ["*"]},
  direction: "undirected",
  load_id: true,
  update: "static"
}

To run a query on hdcGraph:

GQL
EXEC{
  MATCH p = ({_id: "A"})-[]-{2}({_id: "C"})
  RETURN p
} ON hdcGraph

Result: p

Limited Graph Traversal Direction

If an HDC graph is created with the direction option set to in or out, graph traversal is restricted to incoming or outgoing edges, respectively. Queries attempting to traverse in the missing direction throw errors or yield empty results.

To create an HDC graph hdcGraph_in_edges of the graph with nodes and incoming edges:

GQL
CREATE HDC GRAPH hdcGraph_in_edges ON "hdc-server-1" OPTIONS {
  nodes: {"*": ["*"]},
  edges: {"*": ["*"]},
  direction: "in",
  load_id: true,
  update: "static"
}

This query attempts to traverse the outgoing edges from node A on hdcGraph_in_edges, but no result will be returned:

GQL
EXEC{
  MATCH p = ({_id: "A"})-[]->()
  RETURN p
} ON hdcGraph_in_edges

Exclusion of Node IDs

If an HDC graph is created with the load_id option set to false, it does not contain the _id values for nodes. Queries referencing _id throw errors or yield empty results.

GQL
CREATE HDC GRAPH hdcGraph_no_id ON "hdc-server-1" OPTIONS {
  nodes: {"*": ["*"]},
  edges: {"*": ["*"]},
  direction: "undirected",
  load_id: false,
  update: "static"
}

This query utilizes _id to filter nodes on hdcGraph_no_id, error occurs as the HDC graph lacks nodes' _id:

GQL
EXEC{
  MATCH p = ({_id: "A"})-[]-{2}({_id: "C"})
  RETURN p
} ON hdcGraph_no_id

Exclusion of Properties

If an HDC graph is created without certain properties, queries referencing these properties throw errors or yield empty results.

To create an HDC graph hdcGraph_no_weight of the graph, which includes all node properties but only the system properties of link edges:

GQL
CREATE HDC GRAPH hdcGraph_no_weight ON "hdc-server-1" OPTIONS {
  nodes: {"*": ["*"]},
  edges: {"link": []},
  direction: "undirected",
  load_id: true,
  update: "static"
}

This query utilizes the weight property to filter edges on hdcGraph_no_weight, but no result will be returned since the HDC graph doesn't have the weight property:

GQL
EXEC{
  MATCH p = ({_id: "A"})-[e]-() WHERE e.weight > 1
  RETURN p
} ON hdcGraph_no_weight