Reputation: 33179
I have simplified my complex cypher down its core issue.
START focus=node(2), user=node(20)
MATCH focus-[:USER_FEED_LIST*1..15]->pointer-[:POINTER]->item,
item-[l?:NOTICE_LINK]->link<-[lu?:POST_UPVOTE]-user
RETURN link, ID(item) as item_id, item, l, lu
Basically what I am trying to achieve is as follows:
l
and link
if they exist, or null if notlink
is not null, return lu
and user
if they exist, or null if notThe problem I am having is with 3.
as the third line of the query is really saying return any link that satisfies either of the given relationships.
So for example, if my linked list chained 10 items, I need the query to always return 10 rows (null for l
, link
and lu
if they don't exist).
Upvotes: 0
Views: 530
Reputation: 41706
Probably you want to go with path expressions and not optional relationships? Those path expressions return a collection of paths. You can use extract / filter to extract certain parts of those.
START focus=node(2), user=node(20)
MATCH focus-[:USER_FEED_LIST*1..15]->pointer-[:POINTER]->item,
RETURN ID(item) as item_id, item, (item-[:NOTICE_LINK]->link<-[:POST_UPVOTE]-user)
Upvotes: 0