Fix BI Q13: use OPTIONAL MATCH, collect pairs and filter out nulls to allow empty lists
/*
:param { country: 'Burma' }
*/
-MATCH (:Country {name: $country})<-[:IS_LOCATED_IN]-(message:Message)-[:HAS_TAG]->(tag:Tag)
+MATCH (:Country {name: $country})<-[:IS_LOCATED_IN]-(message:Message)
+OPTIONAL MATCH (message)-[:HAS_TAG]->(tag:Tag)
WITH
message.creationDate/10000000000000 AS year,
message.creationDate/100000000000%100 AS month,
@@ -14,6 +15,10 @@ WITH
year,
month,
collect([tag.name, popularity]) AS popularTags
+WITH
+ year,
+ month,
+ [popularTag IN popularTags WHERE popularTag[0] IS NOT NULL] AS popularTags
RETURN
year,
month,
