Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
on 02-21-2019 02:59 AM
MATCH (:Institute {instituteName:'aaa school'}) <-[r:WORKED_IN]-(:Author)<-[:WRITTEN_BY]-(p:Paper)-[:WRITTEN_BY]->(:Author)-[:WORKED_IN]->(:Institute {instituteName: 'bbb school'})
RETURN p LIMIT 25
Anyone knows how to rewrite this code such that i can obtain the paper written together by authors from more schools?
Try this:
MATCH (a1:Author)-[r:WORKED_IN]->(:Institute {instituteName:'aaa school'})
MATCH (a2:Author)-[:WORKED_IN]->(:Institute {instituteName: 'bbb school'})
WITH a1, a2
MATCH(p:Paper)-[:WRITTEN_BY]->(a1)
OPTIONAL MATCH (p)-[:WRITTEN_BY]->(a2)
RETURN p LIMIT 25;
Could you use a recursion strategy? Here's an example query on the Movie Graph that will search 2 levels deep. m:Movie
would be the paper, p:Person
would be your author, m2:Movie
would be your school in your model.
match (m:Movie {title: "A Few Good Men"})-[*1..2]-(p:Person)-[]-(m2:Movie)
return *