Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex Neo4j 2.0标签名称通配符搜索_Regex_Wildcard_Cypher_Neo4j - Fatal编程技术网

Regex Neo4j 2.0标签名称通配符搜索

Regex Neo4j 2.0标签名称通配符搜索,regex,wildcard,cypher,neo4j,Regex,Wildcard,Cypher,Neo4j,在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; 我想用标签名做同样的事情。我想获得所有包含特定字符串的唯一标签。比如: Match (n)-[:IS_A]-() wh

在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;
我想用标签名做同样的事情。我想获得所有包含特定字符串的唯一标签。比如:

 Match (n)-[:IS_A]-() where (n:Course_*_001) return distinct n;
塞弗能做到吗?还是餐馆?正则表达式


我使用的是Neo4j 2.0版本。

您不能在标签上直接使用正则表达式。但是,使用
标签
功能可以:

MATCH (n)-[:IS_A]->() 
WHERE any(l IN labels(n) WHERE l=~'Course_*_001')
RETURN distinct n;

请注意,此查询可能会很昂贵,因为它涉及数据库中的所有节点。您可能希望重构数据模型以使用多个标签,例如
Course
Course\u xyz\u 001
。在这种情况下,您可以使用
MATCH(n:Course)…
来减少首先要访问的节点数。

+1在多个标签上,或者使用
:Course(type)
上的索引,并在
type
属性中添加“Driving_001”。但这可能会慢一些。即使有多个标签,我认为这最终也会太慢。我想我会尝试将标签名称存储在它们自己的图表中,无论何时创建一个新的图表。这样我就能很快找到他们。不过,我可以用你的例子来说明其他情况。谢谢