YMatrix
Quick Start
Connecting
Benchmarks
Deployment
Data Usage
Manage Clusters
Upgrade
Global Maintenance
Expansion
Monitoring
Security
Best Practice
Technical Principles
Data Type
Storage Engine
Execution Engine
Streaming Engine(Domino)
MARS3 Index
Extension
Advanced Features
Advanced Query
Federal Query
Grafana
Backup and Restore
Disaster Recovery
Graph Database
Introduction
Clauses
Functions
Advanced
Guide
Performance Tuning
Troubleshooting
Tools
Configuration Parameters
SQL Reference
SELECT * FROM cypher('graph_name', $$
CREATE (:Person {name: 'John'}),
(:Person {name: 'Jeff'}),
(:Person {name: 'Joan'}),
(:Person {name: 'Bill'})
$$) AS (result agtype);
Performs a case-sensitive prefix search on strings.
SELECT * FROM cypher('graph_name', $$
MATCH (v:Person)
WHERE v.name STARTS WITH "J"
RETURN v.name
$$) AS (names agtype);
Result
| names |
|---|
| "John" |
| "Jeff" |
| "Joan" |
| 3 rows |
Performs a case-sensitive substring search on strings.
SELECT * FROM cypher('graph_name', $$
MATCH (v:Person)
WHERE v.name CONTAINS "o"
RETURN v.name
$$) AS (names agtype);
Result
| names |
|---|
| "John" |
| "Joan" |
| 2 rows |
Performs a case-sensitive suffix search on strings.
SELECT * FROM cypher('graph_name', $$
MATCH (v:Person)
WHERE v.name ENDS WITH "n"
RETURN v.name
$$) AS (names agtype);
Result
| names |
|---|
| "John" |
| "Joan" |
| 2 rows |
AGE supports POSIX regular expressions using the =~ operator, as documented in the PostgreSQL POSIX Regular Expression documentation. By default, =~ is case-sensitive.
When no special regex characters are present, =~ behaves identically to =.
SELECT * FROM cypher('graph_name', $$
MATCH (v:Person)
WHERE v.name =~ 'John'
RETURN v.name
$$) AS (names agtype);
Result
| names |
|---|
| "John" |
| 1 row |
Prepend (?i) to the pattern to perform a case-insensitive match.
SELECT * FROM cypher('graph_name', $$
MATCH (v:Person)
WHERE v.name =~ '(?i)JoHn'
RETURN v.name
$$) AS (names agtype);
Result
| names |
|---|
| "John" |
| 1 row |
. WildcardThe . matches any single character.
SELECT * FROM cypher('graph_name', $$
MATCH (v:Person)
WHERE v.name =~ 'Jo.n'
RETURN v.name
$$) AS (names agtype);
Result
| names |
|---|
| "John" |
| "Joan" |
| 2 rows |
* QuantifierThe * quantifier matches zero or more occurrences of the preceding character.
SELECT * FROM cypher('graph_name', $$
MATCH (v:Person)
WHERE v.name =~ 'Johz*n'
RETURN v.name
$$) AS (names agtype);
Result
| names |
|---|
| "John" |
| 1 row |
+ QuantifierThe + quantifier matches one or more occurrences of the preceding character.
SELECT * FROM cypher('graph_name', $$
MATCH (v:Person)
WHERE v.name =~ 'Bil+'
RETURN v.name
$$) AS (names agtype);
Result
| names |
|---|
| "Bill" |
| 1 row |
. and *The . and * can be combined to match the remainder of a string.
SELECT * FROM cypher('graph_name', $$
MATCH (v:Person)
WHERE v.name =~ 'J.*'
RETURN v.name
$$) AS (names agtype);
Result
| names |
|---|
| "John" |
| "Jeff" |
| "Joan" |
| 3 rows |
The following table lists operator precedence in AGE, from highest to lowest:
| Precedence | Operator | Description |
|---|---|---|
| 1 | . |
Property access |
| 2 | [] |
Map and list subscripting |
() |
Function invocation | |
| 3 | STARTS WITH |
Case-sensitive string prefix match |
ENDS WITH |
Case-sensitive string suffix match | |
CONTAINS |
Case-sensitive string substring match | |
=~ |
Regular expression match | |
| 4 | - |
Unary minus |
| 5 | IN |
Checks whether an element exists in a list |
IS NULL |
Tests whether a value is NULL |
|
IS NOT NULL |
Tests whether a value is not NULL |
|
| 6 | ^ |
Exponentiation |
| 7 | * / % |
Multiplication, division, modulo |
| 8 | + - |
Addition and subtraction |
| 9 | = <> |
Equality and inequality (≠) |
< <= |
Less-than and less-than-or-equal | |
> >= |
Greater-than and greater-than-or-equal | |
| 10 | NOT |
Logical negation |
| 11 | AND |
Logical conjunction |
| 12 | OR |
Logical disjunction |