Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-04-2021 11:17 AM
I have modeled an schema for an internal business process.
Below an example of my data:
In the example above John
works for two different companies, but for the given process he used both companies' logins to interact in the same process.
My question is: How can I query all the Process
where both logins of John
was used in the same process ?
Below a cypher query that I was playing without success.
MATCH (person:Person {name: "John"}),
(company1:Company {name: "Company2"}),
(company2:Company {name: "Company3"}),
(person)-[:WORKS_FOR]->(company1),
(person)-[:WORKS_FOR]->(company2),
(person)<-[c:CHANGED_BY]-(e:Event),
(e)-[p:BELONGS_TO]->(process:Process)
WHERE
(company1.name = c.company_name or company2.nome = c.company_name)
RETURN DISTINCT person.name AS Person, company1.name AS Company1, Company2.name AS Company2, process.id AS ProcessNro
Solved! Go to Solution.
01-05-2021 07:30 AM
@kleysonr as my answer's note said, the result returned by cypher query is not filtered by company's name. To do so put the below where:
MATCH (p:Person {name: "John"})-[:WORKS_FOR]->(c:Company),
(e:Event)-[:CHANGED_BY]->(p),
(e)-[:BELONGS_TO]->(pss:Process)
WHERE c.name IN ["Company 2","Company 3"]
RETURN {name:p.name,companies:COLLECT(DISTINCT c.name),processes:COLLECT(DISTINCT pss.id)} As result
01-04-2021 12:58 PM
@kleysonr The below cypher query may respond to your question:
MATCH (p:Person {name: "John"})-[:WORKS_FOR]->(c:Company),
(e:Event)-[:CHANGED_BY]->(p),
(e)-[:BELONGS_TO]->(pss:Process)
RETURN {name:p.name,companies:COLLECT(DISTINCT c.name),processes:COLLECT(DISTINCT pss.id)} As result
Note that John
is working in two or more Companies;
The above cypher query is not filtered by company's name but they are returned in array(all affected companies names).
01-05-2021 04:35 AM
@jhakiz Thanks for the answer, but the query is bringing all the process where John is connected.
I'm looking for a different answer.
Based on the image above, John works for 2 companies at the same time. But for the process XT02145-1
he did a login using his account of Comapny 2
and did some change on the process. Then he did a logout of Company 2
and did a new login using his account of Company 3
and again changed the process.
I'm looking for all the process where John had the same behavior. So, he used different accounts to execute different actions in the same process.
01-05-2021 07:30 AM
@kleysonr as my answer's note said, the result returned by cypher query is not filtered by company's name. To do so put the below where:
MATCH (p:Person {name: "John"})-[:WORKS_FOR]->(c:Company),
(e:Event)-[:CHANGED_BY]->(p),
(e)-[:BELONGS_TO]->(pss:Process)
WHERE c.name IN ["Company 2","Company 3"]
RETURN {name:p.name,companies:COLLECT(DISTINCT c.name),processes:COLLECT(DISTINCT pss.id)} As result
All the sessions of the conference are now available online