Update bi-10.cypher (w/o pattern comprehension version) to contain aggregation only at the top level of return expression
@@ -11,7 +11,8 @@ OPTIONAL MATCH (tag)<-[interest:HAS_INTEREST]-(person:Person)
WITH tag, collect(person) AS interestedPersons
OPTIONAL MATCH (tag)<-[:HAS_TAG]-(message:Message)-[:HAS_CREATOR]->(person:Person)
WHERE message.creationDate > $date
-WITH tag, interestedPersons + collect(person) AS persons
+WITH tag, interestedPersons, collect(person) AS persons
+WITH tag, interestedPersons + persons AS persons
UNWIND persons AS person
// poor man's disjunct union (should be changed to UNION + post-union processing in the future)
WITH DISTINCT tag, person
@@ -19,13 +20,18 @@ OPTIONAL MATCH (tag)<-[interest:HAS_INTEREST]-(person:Person)
WITH
tag,
person,
- 100 * count(interest) AS score
+ count(interest) AS score // multiple by 100 deferred to next query part
OPTIONAL MATCH (tag)<-[:HAS_TAG]-(message:Message)-[:HAS_CREATOR]->(person)
WHERE message.creationDate > $date
WITH
tag,
person,
- score + count(message) AS score
+ 100 * score AS score,
+ count(message) AS messageCount
+WITH
+ tag,
+ person,
+ score + messageCount AS score
MATCH (person)-[:KNOWS]-(friend)
WITH
tag,
@@ -38,14 +44,20 @@ WITH
person,
score,
friend,
- 100 * count(interest) AS friendScore
+ count(interest) AS friendScore // multiple by 100 deferred to next query part
OPTIONAL MATCH (tag)<-[:HAS_TAG]-(message:Message)-[:HAS_CREATOR]->(friend)
WHERE message.creationDate > $date
WITH
person,
score,
friend,
- friendScore + count(message) AS friendScore
+ 100 * friendScore AS friendScore,
+ count(message) AS messageCount
+WITH
+ person,
+ score,
+ friend,
+ friendScore + messageCount AS friendScore
RETURN
person.id,
score,
