Is the depth in custom Cypher queries with OGM always 0?

I am currently evaluating OGM / Spring Data Neo4j for use and came up with the following problem:

When executing a custom Cypher query, either using Spring Data annotation @Query

or directly through Neo4j Session

, the result only contains the nodes directly requested for and unrelated nodes (relations null

in the resulting node objects). That is, the depth for these queries seems to be 0 and not 1 as I expected from the docs.

How do I execute a custom Cypher query through OGM or Spring Data Neo4j with depth 1?

+3


source to share


1 answer


By default, depth 1 refers to findOne / findAll / .. methods from the repository and retrieved search engines.

This is what the documentation says about custom queries:

In the current release, custom queries do not support paging, sorting, or custom depth. Also, it does not support path matching to domain objects, so the path should not be returned from a Cypher query. Instead, return the nodes and relationships so that they are mapped to domain objects.

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



For example, if you have a query

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

      

list all the nodes / relationships you want to map to your entities in the RETURN clause.

+4


source







All Articles