Collecting ids of two separate nodes and using them in subsequent cyphers

I'm trying to use the jaccard algorithm to calculate the similarity between two nodes. However, whenever I run the queries given by the documentation and adapt them to my own use case I get "(no changes, no records).

My first step was to backtrack and see if I could write a cypher to return the ids of the neighbors of the two ndoes that I want to compare. The cypher that I came up with is as follows:

``````MATCH (p1:User {name: "squintingkiwi"})-[LISTENS_TO]->(artist1)
MATCH (p2:User {name: "bubblegum"})-[:LISTENS_TO]->(artist2)
return collect(id(artist1)), collect(id(artist2))

collect(id(artist1))	collect(id(artist2))
[]	[]
``````

However, when I run this query it returns two empty lists. Now I know for a fact that these two nodes do have adjacent nodes since when I run this cypher I get a list of the ids of the neighboring nodes:

``````MATCH (p1:User {name: 'squintingkiwi'})-[:LISTENS_TO]->(artist1)
WITH p1, collect(id(artist1)) AS p1Tastes RETURN p1Tastes
``````
``````╒═════════════════════════════════════════════════════════════╕
│"p1Tastes"                                                  │
╞═════════════════════════════════════════════════════════════╡
│[31,30,29,28,27,26,25,24,23,22,21,20,11,10,9,8,7,6,5,4,3,2,1]│
└─────────────────────────────────────────────────────────────┘
``````

However when I try to incorporate a second node all the data that I've collected seems to get lost. Can anyone explain to me why this might be happening?

Thanks,
Daman

Try this:

MATCH (p1:User {name: "squintingkiwi"})-[LISTENS_TO]->(artist1)
WITH p1, collect(id(artist1)) AS p1Tastes

MATCH (p2:User {name: "bubblegum"})-[:LISTENS_TO]->(artist2)
WITH p1, p1Tastes, p2, collect(id(artist2)) AS p2Tastes

RETURN p1.name AS from, p2.name AS to,
algo.similarity.jaccard(p1Tastes, p2Tastes) AS similarity