Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.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
spring-data-neo4j:@Query with depth_Neo4j_Cypher_Spring Data Neo4j_Spring Data Neo4j 4 - Fatal编程技术网

spring-data-neo4j:@Query with depth

spring-data-neo4j:@Query with depth,neo4j,cypher,spring-data-neo4j,spring-data-neo4j-4,Neo4j,Cypher,Spring Data Neo4j,Spring Data Neo4j 4,我使用的是spring-data-neo4jv4.2.8。 我有一个节点与2个实体关系一个用于传入,另一个用于传出 我想使用repository@Query方法加载带有特定过滤器的节点所有关系都应与节点一起加载。这是我的问题 @Query(value = "MATCH (n:`Person`) WHERE {0} IN labels(n) RETURN n") Iterable<Person> findAllByLabels(String label); 在这种情况下,仅加载具有关

我使用的是
spring-data-neo4j
v4.2.8
。 我有一个
节点
与2个
实体关系
一个用于传入,另一个用于传出

我想使用repository@Query方法加载带有特定过滤器的节点所有关系都应与节点一起加载。这是我的问题

@Query(value = "MATCH (n:`Person`) WHERE {0} IN labels(n) RETURN n")
Iterable<Person> findAllByLabels(String label);
在这种情况下,仅加载具有关系的节点,并且存在其他问题

我有什么办法可以让这一切顺利进行呢


谢谢。

这是我目前找到的解决方案

@Query(value = "MATCH (n:`Person`) WHERE {0} IN labels(n) MATCH (n1:`Person`)<-[r1]-(n2:`Person`) WHERE {0} IN labels(n1) RETURN n,n1,n2,r1")

@Query(value=“MATCH(n:`Person`))其中标签(n)中的{0}匹配(n1:`Person`)与下面的匹配,您可以返回每个节点,即使它没有关系

@Query(value = "MATCH (n:`Person`) WHERE {0} IN labels(n)"
      + " OPTIONAL MATCH path=(n:`Person`)<-[r]-()"
      + " RETURN CASE path WHEN null THEN n ELSE path END")
  Iterable<Person> findAllByLabels(String label);
@Query(value=“MATCH(n:`Person`)其中标签中的{0}(n)”
+“可选匹配路径=(n:`Person`)
@Query(value = "MATCH (n:`Person`) WHERE {0} IN labels(n)"
      + " OPTIONAL MATCH path=(n:`Person`)<-[r]-()"
      + " RETURN CASE path WHEN null THEN n ELSE path END")
  Iterable<Person> findAllByLabels(String label);