Cypher API
此文档主要介绍了TuGraph-Cypher的详细使用说明
1.Operators
1.1.Summary
Operators支持进度一览:
类别 | 支持 | 待支持 |
---|---|---|
General operators | DISTINCT , . for property access | [] for dynamic property access |
Mathematical operators | + , - , * , / , % , ^ | |
Comparison operators | = , <> , < , > , <= , >= , IS NULL , IS NOT NULL | |
String-specific comparison operators | STARTS WITH , ENDS WITH , CONTAINS , REGEXP | |
Boolean operators | AND , OR , XOR , NOT | |
String operators | + for concatenation | |
List operators | + for concatenation, IN to check existence of an element in a list, [] for accessing element(s) |
1.2.General operators
- ✓ Using the DISTINCT operator
MATCH (p:person) RETURN DISTINCT p.born
- ❏ Accessing properties of a nested literal map using the
.
operator
WITH {person: {name: 'Anne', age: 25}} AS p
RETURN p.person.name
- ❏ Filtering on a dynamically-computed property key using the
[]
operator
CREATE (a:Restaurant {name: 'Hungry Jo', rating_hygiene: 10, rating_food: 7}),
(b:Restaurant {name: 'Buttercup Tea Rooms', rating_hygiene: 5, rating_food:6}),
(c1:Category {name: 'hygiene'}), (c2:Category {name: 'food'})
MATCH (restaurant:Restaurant), (category:Category)
WHERE restaurant["rating_" + category.name] > 6
RETURN DISTINCT restaurant.name
1.3.Mathematical operators
- ✓ Using the exponentiation operator
^
WITH 2 AS number, 3 AS exponent
RETURN number ^ exponent AS result
- ✓ Using the unary minus operator
-
WITH -3 AS a, 4 AS b
RETURN b - a AS result
1.4.Comparison operators
- ✓ Comparing two numbers
WITH 4 AS one, 3 AS two
RETURN one > two AS result
1.5.String-specific comparison operators
- ✓ Using STARTS WITH to filter names
WITH ['John', 'Mark', 'Jonathan', 'Bill'] AS somenames
UNWIND somenames AS names
WITH names AS candidate
WHERE candidate STARTS WITH 'Jo'
RETURN candidate
- ✓ Using REGEXP to filter names
WITH ['John', 'Mark', 'Jonathan', 'Bill'] AS somenames
UNWIND somenames AS names
WITH names AS candidate
WHERE candidate REGEXP 'Jo.*n'
RETURN candidate
1.6.Boolean operators
- ✓ Using boolean operators to filter numbers
WITH [2, 4, 7, 9, 12] AS numberlist
UNWIND numberlist AS number
WITH number
WHERE number = 4 OR (number > 6 AND number < 10)
RETURN number
1.7.String operators
String operators comprise:
- ✓ concatenating strings:
+
1.8.List operators
- ✓ Concatenating two lists using +
RETURN [1,2,3,4,5]+[6,7] AS myList
- ✓ Using IN to check if a number is in a list
WITH [2, 3, 4, 5] AS numberlist
UNWIND numberlist AS number
WITH number
WHERE number IN [2, 3, 8]
RETURN number
- ✓ Accessing elements in a list using the [] operator
WITH ['Anne', 'John', 'Bill', 'Diane', 'Eve'] AS names
RETURN names[1..3] AS result