Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

224
Visualizações
Specify the direction in findBy Spring data Neo4J queries with depth > 0

I use SDN 4.2.1 to save and load nodes and their relationships in Neo4J.

Until now, I was using findByXXX methods with a depth param equal to 2. Now I need to increase the depth to 3, but the query is far to slow, and I know why : the executed query is not considering the direction of the relationships.

Here is the executed query from the logs (take more than 20 seconds) :

o.n.o.drivers.bolt.request.BoltRequest   : Request: MATCH (n:`Property`) WHERE n.`id` = { `id_0` } WITH n MATCH p=(n)-[*0..3]-(m) RETURN p, ID(n) with params {id_0=P31}

When I rewrite the query with a direction, it becomes very fast :

MATCH (n:`Property`) WHERE n.`id` = "P31" WITH n MATCH p=(n)-[*0..3]->(m) RETURN p, ID(n)

I can't find a way to specify that, in my case, I only want "outgoing" relationships in the findByXXX function declaration of my GraphRepository interface. Is there a parameter like the "@Depth" annotation to give the direction ?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

There is currently no way of declaring more fine grained queries through annotations. Actually, having some hints in the code about (not) following some paths can be good for a particular use case, but is irrelevant for others.

Looking at what is done for example on JPA : you can use annotations to eagerly load dependent objects. But once an application grows you have to manage FetchProfiles or NamedEntityGraphs to handle the way you fetch according to the use case.

That is why, with SDN 4.x, the preferred way of doing this is to use custom cypher queries. It will ensure you to pick up only the data you need in a performant way.

There is an issue to track this here. Note that it is one of improvements planned for the next major release of OGM / SDN. If you have specific use cases you need to address or ideas around this, feel free to open a discussion on the the slack channel neo4j-users.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda