cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Query ShortPath based on Attribute

Hi All,
Someone already tried to get one Path based on some attribute ? I'm trying this one:
MATCH (r1:EndNode { Name:'aaa'}),(r2:EndNode { Name:'bbb'})
MATCH p = allShortestPaths((r1)-[r*]-(r2)) WHERE r.Denied <> 'TESTONE' return p
Without WHERE cause works. but when I try to filter doesn't works.

3 REPLIES 3

Hi @fabiooliveirasantos

Neo4j 4.2.1

This is the data.

CREATE (r1:EndNode {Name: 'aaa'})-[:REL {Denied: 'HOGEHOGE'}]->(r2:EndNode {Name: 'bbb'}),
       (r1)-[:REL {Denied: 'TESTONE'}]->(:EndNode {Name: 'ccc'})-[:REL {Denied: 'TESTONE'}]->(r2),
       (r1)-[:REL {Denied: 'TESTONE'}]->(:EndNode {Name: 'ddd'})-[:REL {Denied: 'TESTONE'}]->(r2);


This Cypher will work with the current version.

MATCH (r1:EndNode {Name: 'aaa'}), (r2:EndNode {Name: 'bbb'})
MATCH p = allShortestPaths((r1)-[r*]-(r2))
  WHERE ALL(r IN relationships(p) WHERE r.Denied = 'TESTONE')
RETURN p;

I think this one doesn't works on 3.4 version, b/c I saw all links (even with Denied set to HOGEHOGE) in result....Any other idea?

I think that the problem is related with Neo4j web browser interface and not server. I made the same query using python (py2neo) and saw the correct topology (avoiding HOGEHOGE edges).. So your query works perfectly. So many thanks Sr.