Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-18-2019 12:39 AM
Hello
I am trying to find neighbour nodes of specific node. In my case I will extend it up to 2 hops . here is my situation
Here the diagram is already showing its 2 hop neighbour hood. My query is given bellow
Match (c:A{ID:'123'})-[*1..2]->(d)
Return Distinct(d)
but for large dataset(8 million) I don't want to include drives relation here for gaining better performance
is there any way to get 2 hops path excluding some specific relation. to be specific I have 2 relations relation like "WASH" and "DRIVES". I want to exclude these relation and create 2hops neighbour hood graph for A node
Kindly help me
12-18-2019 01:35 AM
Technically you can exclude relationship types like this:
Match (c:A{ID:'123'})-[r*1..2]->(d)
where none(x in r WHERE type(x) in ['DRIVES', 'WAHS'])
Return Distinct(d)
However this will touch also the DRIVES
and WASH
relationships just to filter them out. It's more performant to provide a positive list if relationship types to traverse:
Match (c:A{ID:'123'})-[:OWNS|:EARN_MONEY*1..2]->(d)
Return Distinct(d)
This will solely touch OWNS
and EARN_MONEY
relationships and not load any other relationship.
12-18-2019 02:13 AM
thanks for your reply . There is a issue created, some of the nodes has self referenced loop "Wash". it is not filtered. and one "drive" relation is still there. this solution is partially filtering
All the sessions of the conference are now available online