Fix BI query 11
// Q11. Unrelated replies
/*
:param {
- country: 'Pakistan',
- blacklist: ['one', 'has', 'David']
+ country: 'Germany',
+ blacklist: ['also', 'Pope', 'that', 'James', 'Henry', 'one', 'Green']
}
*/
WITH $blacklist AS blacklist
MATCH
(country:Country {name: $country})<-[:IS_PART_OF]-(:City)<-[:IS_LOCATED_IN]-
- (person:Person)<-[:HAS_CREATOR]-(reply:Comment)-[:REPLY_OF]-(message:Message),
+ (person:Person)<-[:HAS_CREATOR]-(reply:Comment)-[:REPLY_OF]->(message:Message),
(reply)-[:HAS_TAG]->(tag:Tag)
OPTIONAL MATCH
- (fan:Person)-[:LIKES]->(reply)
-WHERE NOT (message)-[:HAS_TAG]->(tag)
+ (:Person)-[like:LIKES]->(reply)
+WHERE NOT (message)-[:HAS_TAG]->(:Tag)<-[:HAS_TAG]-(reply)
AND size([word IN blacklist WHERE reply.content CONTAINS word | word]) = 0
RETURN
person.id,
tag.name,
- count(fan) AS countLikes,
- count(reply) AS countReplies,
+ count(DISTINCT like) AS countLikes,
+ count(DISTINCT reply) AS countReplies,
reply.content
ORDER BY
countLikes DESC,
