Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-09-2020 10:58 AM
Hi Group !
I'm a very basic and newbie user of neo4J and Cypher and I'm trying to build a query.
This is about the visibility of a Component in an application given a set of eligibility conditions (items) for the Employee that is connected to the application.
the data model:
What I'm trying ?
my (very bad) attempts
match (ee:Employee {name:"Carlos"})-[:EE_Eligible_For]->(o:EligibilityItem) with ee, collect(o.name) as l1
match (:Component {name:"HEALTH_ACCORDION"})-[:Is_Eligible_For]->(e:EligibilityItem)
with collect(e.name) as l2, collect (o.name) as l2 return apoc.coll.intersection (l1, l2)
// fetch the eligibility items for the component
match (c:component {key:"HEALTH_ACCORDION"})->[:Is_Eligible_For]->(e:EligibilityItem)
with c,collect(e) as ComponentEList
// fetch the eligibility items for the logged user
match (ee:Employee {name:"Carlos")->[:EE_Eligible_For]->(e2:EligibilityItem)
with ee, collect(e2) as EmployeeEList
match (sal:SalaryClass) where ee.salary > sal.min and ee.salary < sal.max
with sal.name + EmployeeEList
// intersect the eligibility list
return apoc.coll.intersect(ComponentEList,EmployeeEList)
Greatly appreciate if you can point me the right direction to achieve my goal.
Running Neo4J 4.0.4
best regards
Rui
Solved! Go to Solution.
06-10-2020 10:41 AM
I've tried and tried and tried again
but i did it !
in short, I was misusing the "WITH" instruction
My solution:
// get eligibility items for employee
match (ee:Employee {name:"Carlos"})-[:EE_Eligible_For]->(e1:EligibilityItem)
with collect(e1.name) as l1
// get eligibility items for component
match (:Component {name:"HEALTH_ACCORDION"})-[:Is_Eligible_For]->(e2:EligibilityItem)
with collect(e2.name) as l2,l1
// check if there is common eligibility items
return apoc.coll.intersection (l1, l2) CommonEligibilityItem, size(apoc.coll.intersection (l1, l2)) as NCommonEligibilityItem
06-10-2020 10:41 AM
I've tried and tried and tried again
but i did it !
in short, I was misusing the "WITH" instruction
My solution:
// get eligibility items for employee
match (ee:Employee {name:"Carlos"})-[:EE_Eligible_For]->(e1:EligibilityItem)
with collect(e1.name) as l1
// get eligibility items for component
match (:Component {name:"HEALTH_ACCORDION"})-[:Is_Eligible_For]->(e2:EligibilityItem)
with collect(e2.name) as l2,l1
// check if there is common eligibility items
return apoc.coll.intersection (l1, l2) CommonEligibilityItem, size(apoc.coll.intersection (l1, l2)) as NCommonEligibilityItem
All the sessions of the conference are now available online