Lis*_*ter 5 regex wildcard neo4j cypher
在Cypher中处理属性时,可以使用正则表达式来匹配属性值,如下所示:
Match (n)-[:IS_A]-() where (n:Course_Driving_001) and (n.name =~ '(?i).*criteria.*' or n.description =~ '(?i).*criteria.*') return distinct n limit 20;
Run Code Online (Sandbox Code Playgroud)
我想用标签名称做同样的事情.我想获得包含特定字符串的所有唯一标签.就像是:
Match (n)-[:IS_A]-() where (n:Course_*_001) return distinct n;
Run Code Online (Sandbox Code Playgroud)
这可以做到Cypher吗?还是RestAPI?常用表达?
我正在使用Neo4j 2.0 Release.
您无法在标签上直接使用正则表达式.但是使用这个labels功能是可能的:
MATCH (n)-[:IS_A]->()
WHERE any(l IN labels(n) WHERE l=~'Course_*_001')
RETURN distinct n;
Run Code Online (Sandbox Code Playgroud)
请注意,此查询可能很昂贵,因为它会触及数据库中的所有节点.您可能希望重构数据模型以使用多个标签,例如Course 和 Course_xyz_001.在这种情况下,您可以使用MATCH (n:Course) ....它来减少首先访问的节点数.
| 归档时间: |
|
| 查看次数: |
2630 次 |
| 最近记录: |