Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-26-2020 03:42 AM
I need your help in neo4j project. I made two nodes Artist and Song. The relationship of these nodes is
(a:Artist)-[:SING]->(s:Song) I want to find all artists with shortest path lengths > 25 from artist ‘John Lennon’. The shortest paths will be calculated only on edges between artists and songs. Also, I want to return artist name, the length and the song titles for each path. I tried the bellow
MATCH (a:Artist { name: 'John Lennon' }), p = shortestPath((a)-[:SING*]-(s:Song))
WHERE ALL (r IN relationships(p) WHERE EXISTS (r.role)) AND length(p) > 25
RETURN a.name as artist ,length(p) as length, s.title
or
MATCH (a:Artist)-[SING*]->(s:Song)
,(Lennon:Aartist),
p = shortestPath((Lennon)-[*]-())
WHERE a.name='John Lennon' AND length(p) > 25
RETURN a.name as artist ,length(p) as length, s.title
But they didn't work.
Any idea what I did wrong?
12-26-2020 04:03 AM
Hi @marianapet55,
Looks like
Artist -> SINGS ( one of more) -> Songs
A Song -> SANG (by one or more) -> Artists
are you looking for the count of songs sung my an artist ???
or a how many artist sang a song ??
12-26-2020 04:38 AM
Hello,
Thank you for your response.
I want to find all artists with shortest path lengths > 25 from artist ‘John Lennon’.
Also the shortest paths will be calculated only on edges between artists and
songs. So i want to know all shortest path from john to others with lengths >25.
12-26-2020 04:52 AM
Can you share your schema ?
All the sessions of the conference are now available online