Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-22-2019 07:00 AM
I have created a property graph of a web site (where Cids are content ids or pages on the site). The movement of users around the site between Cids / pages is captured by the directed USER_MOVEMENT {weight: integer} relationship. It has a weight associated, the aggregated count of the number of people moving between those Cids in a given time period.
I start by filtering the Cid nodes for a given criteria, to do with their influence around the cite. I'm interested in the top 10
// Only find content that have a pagerank score in the top X% of content
MATCH (u:Cid) WHERE u.pagerank > 7.775
// Find the top 10 of those users
WITH u ORDER BY u.pagerank DESC LIMIT 10
RETURN u.name AS name, u.pagerank AS pageRank, apoc.node.degree.out(u, 'USER_MOVEMENT') AS pathsOut, apoc.node.degree.in(u, 'USER_MOVEMENT') AS pathsIn,
apoc.any.property('USER_MOVEMENT[>]', 'weight') AS usersOut
;
I've tried a few combinations of the last line of code to no avail. The guidance is a bit unclear apoc.any.property(node/rel/map)
i.e.
apoc.any.property(u, 'USER_MOVEMENT>', 'weight') AS usersOut
To total the weights I would need to put into sum()
function.
Any pointers or online help would be welcome
07-23-2019 02:23 PM
Can you try this query?
// Only find content that have a pagerank score in the top X% of content
MATCH (u:Cid) -[r:USER_MOVEMENT]-> ()WHERE u.pagerank > 7.775
// Find the top 10 of those users
WITH u ORDER BY u.pagerank DESC LIMIT 10
RETURN u.name AS name, u.pagerank AS pageRank, apoc.node.degree.out(u, 'USER_MOVEMENT') AS pathsOut, apoc.node.degree.in(u, 'USER_MOVEMENT') AS pathsIn, sum(
r.weight) AS usersOut
;
07-24-2019 04:54 AM
#### Neo.ClientError.Statement.SyntaxError
Neo.ClientError.Statement.SyntaxError: Variable `r` not defined (line 6, column 1 (offset: 370)) "r.weight) AS usersOut" ^
Thanks @anthapu, I also thought of trying this approach, but it fails as r is not defined. Is it because we are not passing r
in the WITH
statement? How might we do that, I'm unsure.
07-24-2019 05:18 AM
I guess we need to rewrite the query like this. Apply match after we get the users of interest to get the relation.
// Only find content that have a pagerank score in the top X% of content
MATCH (u:Cid) WHERE u.pagerank > 7.775
// Find the top 10 of those users
WITH u ORDER BY u.pagerank DESC LIMIT 10
MATCH (u)-[r:USER_MOVEMENT]-> ()
RETURN u.name AS name, u.pagerank AS pageRank, apoc.node.degree.out(u, 'USER_MOVEMENT') AS pathsOut, apoc.node.degree.in(u, 'USER_MOVEMENT') AS pathsIn, sum(
r.weight) AS usersOut
;```
07-24-2019 06:03 AM
You are my hero, thanks!
All the sessions of the conference are now available online