我目前正在评估 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.
例如,当您有查询时
MATCH (n:MyLabel)-[r]-(n2)
WHERE ... // some condition
RETURN n,r,n2
列出您想要映射到 RETURN 子句中的对象的所有节点/关系。
关于neo4j - OGM 的自定义 Cypher 查询的深度始终为 0?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43459968/