简体   繁体   English

Neo4j-路径查询性能

[英]Neo4j - Performance on path query

I have to found all paths between two nodes. 我必须找到两个节点之间的所有路径。 The length of each path has to be beetween 1 and 5 ( 2 and 3 for this exemple ). 每个路径的长度必须介于1到5之间(此示例为2到3)。

So i'm using this query : 所以我正在使用此查询:

profile match p = (a:Station {name : 'X'} ) - [r*2..3] -> (b:Station {name : 'Y'} ) return distinct p

I have an index on :Station(name) 我在:Station(name)上有一个索引

but when I profile this query I have this result : 但是当我配置此查询时,我得到以下结果:

我查询的个人资料 So the problem is neo4j takes every relationship possible for this node B and then filters using the name. 因此问题是neo4j对该节点B采取了所有可能的关系,然后使用该名称进行过滤。 Is it a way for just taking the relation which involved this two specific nodes ? 这是仅采用涉及这两个特定节点的关系的一种方法吗?

Maybe you might want to use allShortestPaths for that, eg : 也许您可能想要为此使用allShortestPaths ,例如:

PROFILE MATCH p=allShortestPaths((n:Person {name:'Ian Robinson'})-[r*1..5]–(b:Person {name:'Michal Bachman'}))
RETURN p

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM