UltipaDocs
Try Playground
  • Introduction
  • Terminologies
    • Reserved Words
    • Data Types
    • Alias
    • Operators
    • Expression
    • Filter
    • Prefix
    • Node and Edge Templates
    • Homologous and Heterologous Data
    • Clause Execution Times
    • Graphset
    • Schema
    • Property
    • Insert
    • Overwrite
    • Upsert
    • Update
    • Delete
    • Find Nodes
    • Find Edges
      • AB
      • Autonet
      • Spread
      • Path Template
      • K-Hop
      • K-Hop Template
    • Find Subgraphs
    • GROUP BY
    • ORDER BY
    • SKIP
    • LIMIT
    • WHERE
    • RETURN
    • WITH
    • UNCOLLECT
    • UNION
    • UNION ALL
    • CALL
    • BATCH
      • Schema Checker
      • Equal
      • Not Equal
      • Less Than
      • Greater Than
      • Less Than or Equal
      • Greater Than or Equal
      • Between
      • Between or Equal
      • Beong to
      • Not Belong To
      • CONTAINS | String
      • CONTAINS | Full-Text
      • Regular Match
      • IS NULL
      • IS NOT NULL
      • And
      • Or
      • Not
      • Exclusive OR
      • DISTINCT
      • toString()
      • toInteger()
      • toFloat()
      • toDouble()
      • toDecimal()
      • toSet()
      • castToRaw()
      • now()
      • dateAdd()
      • dateDiff()
      • year()
      • month()
      • day()
      • dayOfWeek()
      • dateFormat()
      • point()
      • distance()
      • pointInPolygon()
      • lower()
      • upper()
      • reverse()
      • startsWith()
      • endsWith()
      • JSON_decode()
      • JSON_merge()
      • trim()
      • ltrim()
      • rtrim()
      • left()
      • right()
      • substring()
      • replace()
      • split()
      • intersection()
      • difference()
      • listUnion()
      • size()
      • head()
      • reduce()
      • listContains()
      • append()
      • pi()
      • pow()
      • sqrt()
      • abs()
      • floor()
      • ceil()
      • round()
      • sin()
      • cos()
      • tan()
      • cot()
      • asin()
      • acos()
      • atan()
      • length()
      • pnodes()
      • pedges()
      • count()
      • sum()
      • max()
      • min()
      • avg()
      • stddev()
      • collect()
      • dedup()
      • CASE
      • table()
      • coalesce()
      • ifnull()
    • Acceleration
    • Index
    • Full-text
    • LTE
    • Real-time Process
    • Backend Task
    • Analytics Node
    • Server Statistics
    • Server Backup
    • Privilege
    • Policy
    • User
  • Trigger
  1. Docs
  2. /
  3. UQL
  4. /
  5. Graphset | Schema | Property

Graphset

Overview

An Ultipa Graph instance allows for the existence of multiple graphsets. Each graphset includes the definition of the graph structure (schemas and properties), graph metadata (nodes and edges), various indexes, processes, tasks, and so on. Sometimes, the terms "graphset" and "graph" are used interchangeably.

A graphset named default is automatically created during the creation of an Ultipa Graph instance. This default graphset is initially empty and can be freely utilized. However, the default graphset is not allowed to be altered (name and description), dropped, or unmounted.

NOTE

In a cluster environment, the unmounting, mounting, and truncating UQLs will be sent to the leader node for execution.

Show Graph

UQL
// Show all graphsets in the instance (via listGraph API)
show().graph()

// Show all graphsets in the instance (via listGraph API)
show().graph("")

// Show the graphset named Sample in the instance
show().graph("Sample")

Example result:

id
name
totalNodestotalEdges
description
status
0default00System default graph!MOUNTED
1Sample112125MOUNTED

The status of a graphset can be mounted, unmounted or mounting. Large graphsets may take some time to finish mounting.

A mounted graphset displays the total number of nodes and edges within it. An unmounted graphset displays 0 for both totalNodes and totalEdges. During the unmounting process, the graphset displays the number of nodes and edges that are currently mounted.

Create Graph

UQL
// Create a graphset named social, and provide description
create().graph("social", "Campus social graph")

// Create a graphset named social
create().graph("social")

// Create multiple graphsets at one time
create()
  .graph("social")
  .graph("transaction", "Bank Card Transaction")

Naming Conventions

Here are the naming conventions for graphsets:

  • Contains 2 to 64 characters.
  • Must start with letters.
  • Allowed characters include letters (A-Z, a-z), underscore (_), and numbers (0-9).

You cannot have two graphsets with the same name.

Use TRY

Create three graphsets at the same time, but one of the names (default) is duplicated with an existing graphset.

UQL
create().graph("newGraph_1").graph("default").graph("newGraph_2")

The creation of the graphset newGraph_1, which was specified before the duplicated graphset, succeeds. However, the one (newGraph_2) specified after the duplicated graphset fails, with the error message Duplicated db name! returned.

UQL
TRY create().graph("newGraph_1").graph("default").graph("newGraph_2")

The creation of the graphsets is the same as above, though the error message is shielded by the TRY prefix, while returning the message SUCCEED.

Alter Graph

UQL
// Alter name and description of the graphset currently named "miniCircle"
alter().graph("miniCircle").set({name: "movieCommunity", description: "Unix Movie Platform"})

// Remove description of the graphset named "movieCommunity"
alter().graph("movieCommunity").set({description: ""})

// Rename the graphset named "movieCommunity"
alter().graph("movieCommunity").set({name: "movComm"})

Unmount Graph

You may unmount temporarily unused graphsets (except the default graphset) to save instance memory. For example, the LTE-ed properties will be unloaded from the memory.

When a graph is unmounted, it’s not allowed to modify or read the schemas, properties, data, etc. within the graph. Unmounted graph can only be mounted, altered or dropped.

UQL
// Unmount a graphset named "LDCC" from the instance memory
unmount().graph("LDCC")

Mount Graph

Newly created graphsets are mounted by default. You may need to manually re-mount any unmounted graphsets.

When a graphset is remounted, its previously LTE-ed properties will be reloaded into the memory; the indexes and full-text indexes will also be automatically recreated as before.

UQL
// Mount a graphset named "LDCC" back to the instance memory
mount().graph("LDCC")

Drop Graph

Dropping a graphset means to delete the entire graphset. The default graphset cannot be dropped.

UQL
// Drop the graphset named "test0831"
drop().graph("test0831")

// Drop multiple graphsets at one time
drop().graph("test0831").graph("test0925")

Truncate Graph

Truncating a graphset only deletes the specified data within the graph, while the graphset itself and its structure (schemas & properties) are retained.

UQL
// Truncate all nodes and edges in the graphset named "PowerGrid"
truncate().graph("PowerGrid")

// Truncate all @bus nodes (and their adjacent edges) in the graphset named "PowerGrid"
truncate().graph("PowerGrid").nodes(@bus)
                                     
// Truncate all @connectsTo edges in the graphset named "PowerGrid"
truncate().graph("PowerGrid").edges(@connectsTo)

// Truncate all nodes (and edges) in the graphset named "PowerGrid"
truncate().graph("PowerGrid").nodes("*")

// Truncate all edges in the graphset named "PowerGrid"
truncate().graph("PowerGrid").edges("*")
NOTE

Note that deleting a node leads to the removal of all edges that are connected to it.

Compact Graph

Compacting a graphset clears invalid and redundant data from the graph on the server disk but does not make any changes to other valid data.

UQL
// Compact the graphset named "PowerGrid"
compact().graph("PowerGrid")
NOTE

Operations related to data manipulation can generate redundant data, such as old records retained after an update or deletion operation. It's suggested to regularly compact graphsets to improve query efficiency.