I am new to neo4j cypher stuff, I am just trying to achieve pagination with SKIP
and LIMIT
.
I have Employee
node and Task node, Employee can have multiple tasks and one task can be assigned to multiple employees.
Employee and Task have assignment
relationship which is created based on task assigned to employee or his department.
Actually there are 100+ tasks which are assigned to eid = 'RD23233' or department= 'R&D'
To get first 50 tasks of employee/employees, I am using below query,
MATCH (e:Employee)-[ass]->(c:Task)
where e.department= 'R&D' or e.eid='RD23233'
WITH distinct c as t,ass,e
ORDER BY t.taskId
SKIP 0 LIMIT 50
RETURN t,ass,e
Here I am getting first 10 tasks only, because it is actually limiting the employee node. Where as I am expecting task nodes.
How to limit task node with this above query?
After multiple try, I could able to create below query which limits the task nodes.
MATCH (e:Employee)-[ass]->(t:Task)
where e.department= 'R&D' or e.eid='RD23233'
WITH distinct t as c
ORDER BY t.karmTaskId DESC
SKIP 0 LIMIT 50
MATCH (e:Employee)-[ass]->(c)
RETURN c,ass,e