字符串运算符

    Note

    CONTAINS

    CONTAINS要求待运算的左右两边都是字符串类型。

    1. nebula> MATCH (s:player)-[e:serve]->(t:team) WHERE id(s) == "player101" \
    2. AND t.name CONTAINS "ets" RETURN s.name, e.start_year, e.end_year, t.name;
    3. +---------------+--------------+------------+-----------+
    4. | s.name | e.start_year | e.end_year | t.name |
    5. +---------------+--------------+------------+-----------+
    6. | "Tony Parker" | 2018 | 2019 | "Hornets" |
    7. +---------------+--------------+------------+-----------+
    8. nebula> GO FROM "player101" OVER serve WHERE (STRING)properties(edge).start_year CONTAINS "19" AND \
    9. properties($^).name CONTAINS "ny" \
    10. YIELD properties($^).name, properties(edge).start_year, properties(edge).end_year, properties($$).name;
    11. | properties($^).name | properties(EDGE).start_year | properties(EDGE).end_year | properties($$).name |
    12. +---------------------+-----------------------------+---------------------------+---------------------+
    13. +---------------------+-----------------------------+---------------------------+---------------------+
    14. nebula> GO FROM "player101" OVER serve WHERE !(properties($$).name CONTAINS "ets") \
    15. YIELD properties($^).name, properties(edge).start_year, properties(edge).end_year, properties($$).name;
    16. +---------------------+-----------------------------+---------------------------+---------------------+
    17. | properties($^).name | properties(EDGE).start_year | properties(EDGE).end_year | properties($$).name |
    18. +---------------------+-----------------------------+---------------------------+---------------------+
    19. | "Tony Parker" | 1999 | 2018 | "Spurs" |
    20. +---------------------+-----------------------------+---------------------------+---------------------+

    (NOT) STARTS WITH

    1. nebula> RETURN 'apple' STARTS WITH 'app', 'apple' STARTS WITH 'a', 'apple' STARTS WITH toUpper('a');
    2. +-----------------------------+---------------------------+------------------------------------+
    3. | ("apple" STARTS WITH "app") | ("apple" STARTS WITH "a") | ("apple" STARTS WITH toUpper("a")) |
    4. +-----------------------------+---------------------------+------------------------------------+
    5. | true | true | false |
    6. +-----------------------------+---------------------------+------------------------------------+
    7. nebula> RETURN 'apple' STARTS WITH 'b','apple' NOT STARTS WITH 'app';
    8. +---------------------------+---------------------------------+
    9. | ("apple" STARTS WITH "b") | ("apple" NOT STARTS WITH "app") |
    10. | false | false |
    11. +---------------------------+---------------------------------+

    正则表达式

    当前仅opencypher兼容语句(MATCHWITH等)支持正则表达式,原生nGQL语句(FETCHGOLOOKUP等)不支持正则表达式。

    1. nebula> RETURN "384748.39" =~ "\\d+(\\.\\d{2})?";
    2. +--------------------------------+
    3. | ("384748.39"=~"\d+(\.\d{2})?") |
    4. +--------------------------------+
    5. | true |
    6. +--------------------------------+
    7. nebula> MATCH (v:player) WHERE v.name =~ 'Tony.*' RETURN v.name;
    8. +---------------+
    9. | v.name |
    10. +---------------+