Why doesn't this relationship negate correctly?

MATCH (m ) -[r]- (n {nid:'123'}),
p = shortestPath((m)-[*..10]-(n))
WHERE NOT((m)-[:similar]-(n))
RETURN p limit 5

I want to find the shortest path between m and n, but they should not be linked by the relationship 'similar'. The query above will return 0 path, but if I remove the WHERE clause, it return all paths.

Do you get results if you use two separate matches, and keep the WHERE NOT clause associated with the first MATCH?

MATCH (m ) -[r]- (n {nid:'123'})
WHERE NOT((m)-[:similar]-(n))
MATCH p = shortestPath((m)-[*..10]-(n))
RETURN p limit 5

Still not, again only if I remove the WHERE clause.

Hi @lingvisa

What's the logic you are trying to implement?

Reading your query, m-r-n is already the shortest Path.

Am I missing something?

Bennu

I want to find shortest paths between two nodes, but exclude paths of a specific relationship 'similar'.

Hi!

So you wanna exclude :Similar from your paths?

Why isn't m queried with an specific property condition as well?

Bennu