neo4j - OGM 的自定义 Cypher 查询的深度始终为 0?

标签 neo4j cypher spring-data-neo4j neo4j-ogm

我目前正在评估 OGM/Spring Data Neo4j 的用例,并遇到以下问题:

当通过 Spring Data @Query 注解或直接通过 Neo4j Session 执行自定义 Cypher 查询时,结果仅包含直接查询的节点,而不包含相关的节点节点(结果节点对象中的关系为 null)。 IE。这些查询的深度似乎是 0 而不是 1,正如我从文档中所期望的那样。

如何通过 OGM 或 Spring Data Neo4j 执行深度为 1 的自定义 Cypher 查询?

最佳答案

默认深度 1 指的是来自存储库和派生查找器的 findOne/findAll/.. 方法。

这是文档中有关自定义查询的内容:

In the current version, custom queries do not support paging, sorting or a custom depth. In addition, it does not support mapping a path to domain entities, as such, a path should not be returned from a Cypher query. Instead, return nodes and relationships to have them mapped to domain entities.

http://docs.spring.io/spring-data/data-neo4j/docs/current/reference/html/#reference:session:loading-entities:cypher-queries

例如,当您有查询时

MATCH (n:MyLabel)-[r]-(n2)
WHERE ... // some condition
RETURN n,r,n2

列出您想要映射到 RETURN 子句中的对象的所有节点/关系。

关于neo4j - OGM 的自定义 Cypher 查询的深度始终为 0?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43459968/

相关文章:

visualization - Neo4j 浏览器 : Display relationship property as edge label not working

neo4j - 如何在 Cypher 中复制节点并在原始节点上设置值

java - 过滤器中的自定义 propertyConverter 在 Neo4j OGM 中被覆盖

neo4j - Neo4 层级遍历

neo4j cypher 匹配命令串联

neo4j - 你可以在 Neo4j 中使用数字来表示关系类型吗?

java - 使用 SDN 的 Neo4j 存储库中的 lucene 查询中的参数?

java - spring-data-neo4j 中的数据建模

java - 将 SDN-4 添加到 GF-3 : Exception while loading the app: IllegalStateException: ContainerBase. addChild : start: org. apache.catalina.LifecycleException

neo4j - 限制联合密码查询的结果