Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-15-2021 11:58 AM
Hello everyone,
I am coming from RDBMS background and I want to know how to model my requirement and how effective the query will be in neo4j.
Requirement:
Relation 1: INTERACTIONS_COUNT
employee_name<-->employee_name
Relation 2: TEAM_OF
employee<-->team_name
Relation 3: ORGANASATION_OF
team_name<-->org_name
problem Statement : Give me most interacted employees(output employee should consist of searched name) of given employee in a particular team and in a particular org.
Eg: Give me most interacted employees of 'sam' whose name consists of 'jam' and whose team name consists of string 'mail' and whose organisation name is 'google'
Input:
So if 'sam' interactes with 'James cameron', 'Jamieson', 'sam Billings' and 'Andrew james' with teams 'google mail', 'google drive', 'google mail' and 'google mail' respectively in org 'google'.
Output:
My output should be 'James cameron' and 'Andrew james' in decreasing order of interaction count.
After seeing the documentation, I felt it is easier to enter my data. But I have no idea how the cypher query looks like since I need to search for sub string for employee name and team name!! Can someone help me with cypher query and will that query be effective in neo4j?
Thank you!
04-16-2021 10:58 AM
Try this:
merge (a:Organization {name: "ABC"})
merge (b:TeamName {name: "T1"})
merge (c:Employee {name: "Sam"})
merge (c1:Employee {name: "James Cameron"})
merge (c2:Employee {name: "Jamieson"})
merge (c3:Employee {name: "Sam Billings"})
merge (c4:Employee {name: "Andre James"})
merge (b1:TeamName {name: "T2"})
merge (a)-[:TEAM_NAME]->(b)
merge (a)-[:TEAM_NAME]->(b1)
merge (b)<-[:TEAM_MEMBER]-(c)
merge (b)<-[:TEAM_MEMBER]-(c1)
merge (b)<-[:TEAM_MEMBER]-(c2)
merge (b1)<-[:TEAM_MEMBER]-(c3)
merge (b1)<-[:TEAM_MEMBER]-(c4)
merge (c)-[:INTERACTS_WITH {count: 2}]->(c1)
merge (c)-[:INTERACTS_WITH {count: 4}]->(c2)
merge (c)-[:INTERACTS_WITH {count: 6}]->(c3)
merge (c)-[:INTERACTS_WITH {count: 1}]->(c4)
Added 8 labels, created 8 nodes, set 12 properties, created 11 relationships, completed after 164 ms.
Run this query get employees with interaction count in descending order.
match (a:Employee)
where a.name = 'Sam'
match (a)-[r:INTERACTS_WITH]-(b)
with distinct b.name as emp, toInteger(r.count) as cnt
return emp, cnt order by cnt desc
Results:
All the sessions of the conference are now available online