字符串运算符
Note
CONTAINS
CONTAINS
要求待运算的左右两边都是字符串类型。
nebula> MATCH (s:player)-[e:serve]->(t:team) WHERE id(s) == "player101" \
AND t.name CONTAINS "ets" RETURN s.name, e.start_year, e.end_year, t.name;
+---------------+--------------+------------+-----------+
| s.name | e.start_year | e.end_year | t.name |
+---------------+--------------+------------+-----------+
| "Tony Parker" | 2018 | 2019 | "Hornets" |
+---------------+--------------+------------+-----------+
nebula> GO FROM "player101" OVER serve WHERE (STRING)properties(edge).start_year CONTAINS "19" AND \
properties($^).name CONTAINS "ny" \
YIELD properties($^).name, properties(edge).start_year, properties(edge).end_year, properties($$).name;
| properties($^).name | properties(EDGE).start_year | properties(EDGE).end_year | properties($$).name |
+---------------------+-----------------------------+---------------------------+---------------------+
+---------------------+-----------------------------+---------------------------+---------------------+
nebula> GO FROM "player101" OVER serve WHERE !(properties($$).name CONTAINS "ets") \
YIELD properties($^).name, properties(edge).start_year, properties(edge).end_year, properties($$).name;
+---------------------+-----------------------------+---------------------------+---------------------+
| properties($^).name | properties(EDGE).start_year | properties(EDGE).end_year | properties($$).name |
+---------------------+-----------------------------+---------------------------+---------------------+
| "Tony Parker" | 1999 | 2018 | "Spurs" |
+---------------------+-----------------------------+---------------------------+---------------------+
(NOT) STARTS WITH
nebula> RETURN 'apple' STARTS WITH 'app', 'apple' STARTS WITH 'a', 'apple' STARTS WITH toUpper('a');
+-----------------------------+---------------------------+------------------------------------+
| ("apple" STARTS WITH "app") | ("apple" STARTS WITH "a") | ("apple" STARTS WITH toUpper("a")) |
+-----------------------------+---------------------------+------------------------------------+
| true | true | false |
+-----------------------------+---------------------------+------------------------------------+
nebula> RETURN 'apple' STARTS WITH 'b','apple' NOT STARTS WITH 'app';
+---------------------------+---------------------------------+
| ("apple" STARTS WITH "b") | ("apple" NOT STARTS WITH "app") |
| false | false |
+---------------------------+---------------------------------+
正则表达式
当前仅opencypher兼容语句(MATCH
、WITH
等)支持正则表达式,原生nGQL语句(FETCH
、GO
、LOOKUP
等)不支持正则表达式。
nebula> RETURN "384748.39" =~ "\\d+(\\.\\d{2})?";
+--------------------------------+
| ("384748.39"=~"\d+(\.\d{2})?") |
+--------------------------------+
| true |
+--------------------------------+
nebula> MATCH (v:player) WHERE v.name =~ 'Tony.*' RETURN v.name;
+---------------+
| v.name |
+---------------+