我修改了示例以使用新的标签功能。
CREATE (shakespeare:author { firstname: 'William', lastname: 'Shakespeare' }), (juliusCaesar { title: 'Julius Caesar' }),
(shakespeare)-[:WROTE_PLAY { year: 1599 }]->(juliusCaesar),
(theTempest { title: 'The Tempest' }),
(shakespeare)-[:WROTE_PLAY { year: 1610}]->(theTempest),
(rsc { name: 'RSC' }),
(production1 { name: 'Julius Caesar' }),
(rsc)-[:PRODUCED]->(production1),
(production1)-[:PRODUCTION_OF]->(juliusCaesar),
(performance1 { date: 20120729 }),
(performance1)-[:PERFORMANCE_OF]->(production1),
(production2 { name: 'The Tempest' }),
(rsc)-[:PRODUCED]->(production2),
(production2)-[:PRODUCTION_OF]->(theTempest),
(performance2 { date: 20061121 }),
(performance2)-[:PERFORMANCE_OF]->(production2),
(performance3 { date: 20120730 }),
(performance3)-[:PERFORMANCE_OF]->(production1),
(billy { name: 'Billy' }),
(review { rating: 5, review: 'This was awesome!' }),
(billy)-[:WROTE_REVIEW]->(review),
(review)-[:RATED]->(performance1),
(theatreRoyal:theatre { name: 'Theatre Royal' }),
(performance1)-[:VENUE]->(theatreRoyal),
(performance2)-[:VENUE]->(theatreRoyal),
(performance3)-[:VENUE]->(theatreRoyal),
(greyStreet { name: 'Grey Street' }),
(theatreRoyal)-[:STREET]->(greyStreet),
(newcastle:city { name: 'Newcastle' }),
(greyStreet)-[:CITY]->(newcastle),
(tyneAndWear { name: 'Tyne and Wear' }),
(newcastle)-[:COUNTY]->(tyneAndWear),
(england { name: 'England' }),
(tyneAndWear)-[:COUNTRY]->(england),
(stratford { name: 'Stratford upon Avon' }),
(stratford)-[:COUNTRY]->(england),
(rsc)-[:BASED_IN]->(stratford),
(shakespeare)-[:BORN_IN]->stratford
询问
MATCH (theater:theatre),
(newcastle:city),
(bard:author),
(newcastle)<-[:STREET|CITY*1..2]-(theater)<-[:VENUE]-()-[p:PERFORMANCE_OF]->()-[:PRODUCTION_OF]->(play)<-[:WROTE_PLAY]-(bard)
WHERE theater.name = "Theatre Royal" AND
newcastle.name = "Newcastle" AND
bard.lastname = "Shakespeare"
RETURN DISTINCT play AS play,count(p) AS performance_count