1
votes

I have a simple test graph that I run this query on:

MATCH p = (l)-[*1..1]->(start)-[*3..3]->(r) where id(start) = 1101 return l,r

This used to work in Neo4j 2.1, but after upgrading to 2.2, it no longer does, giving this error:

Don't know how to compare that. Left: [:has_participant[1027]{}] ($colon$colon); Right: :sampled[1025]{} (RelationshipProxy)

This query works:

MATCH p = (l)-[*1..1]->(start)-[*1..1]->(r) where id(start) = 1101 return l,start,r

Resulting in this visualisation:

The left node is (l), John node is (start) and the green nodes are (r).

If I double click on the green nodes, and then double-click on the nodes that appear, I can get to my intended (r) nodes, which are labelled as lanes:

Each "level" in this tree is joined with different relationships; 'has_participants' connects (l) to (start), and 'sampled' connects (start) to the green nodes. 'prepared' connects green to blue, and 'sequenced' connects blue to pink.

Given (start), how do I get to (l) and the 2 pink Lane nodes shown above without encountering the error? What I'm actually trying to do is a generic "give me descendant nodes of (start) that are at least 3 steps away", so I can't use knowledge of the sampled->prepared->sequenced relationship path.

Here's the result of EXPLAIN on the problem query:

enter image description here

This variant on the query works:

MATCH p = (l)-->(start)-[*3..3]->(r) where id(start) = 1101 return l,r

But why has my original query stopped working? What if I wanted to do 2..2 on the left?

Edit: in fact, even stranger is that these work:

MATCH p = (l)-[*0..1]->(start)-[*3..3]->(r) where id(start) = 1101 return l,r
MATCH p = (l)-[*1..2]->(start)-[*3..3]->(r) where id(start) = 1101 return l,r

Only 1..1 on the left fails.

1

1 Answers

0
votes

You really should not be using id() functions for querying - they can change.

What happens if you do

MATCH p = (l)-[*1..1]->(start {name:"John"})-[*3..3]->(r) return l,r

You probably want to put an index on the "start" node's label/property.