Is there any way to have a dynamic START clause, where the node/rel ID or index query comes from a preceding WITH?
(You can of course parametrize the START clause; I mean where the value isn't known in advance, but rather derived within the query itself.)
Here's the scenario I'm thinking of: node A is a supernode with a million relationships of type X, and just one of type Y. We want to follow the Y relationship efficiently.
We could use a global relationship index to index that Y relationship with something associating it to node A.
But in the spirit of graph databases ("index-free adjacency"), I was wondering why not store the Y relationship's ID as a property on node A? Then you could efficiently fetch the Y relationship if you had node A.
I presume I could do this in Gremlin, but I was hoping it'd be possible in Cypher. Something like:
START n=node({id})
WITH n, n.yRelId as yRelId
START r=relationship(yRelId)
MATCH n -[r]-> foo
RETURN foo
(I'm assuming btw that `MATCH n -[r]-> foo` will be optimized to not scan all of n's relationships if `r` is already a START point. I hope that's indeed the case?)
If this isn't possible today, please consider this a feature request. =) Happy to file an issue if so.
Thanks!
Aseem