Question

I can't claim I am new to cypher anymore as I am playing with it for over couple of month now, but still struggle with some type of queries. I was wondering if someone can help me with these type of queries.

Suppose if I have order data with the following multi labels nodes:

(o:Order:Active:New) or (o:Order:Active:InProcess) or (o:Order:Active:Approved) or (o:Order:Closed)

and have relationship as

(c:Customer)-[:PLACED_ORDER]-(o)-[:APPROVED_BY]->(e:Employee), (o)-[:HAS_CONSTRAINTS]->(dc:DateConstraint)

Assuming all of these nodes have InternalId property on it.

  1. How can I find all the orders for a customer that are Active and New or Active and Inprocess but not Active and Approved. Basically looking to query for multiple Labels.
  2. How can I find all the orders that are approved by someone else i.e. orders approved by other employees than the InternalId of the employee I have.
  3. How can i query for all the orders that does not have a constraints, i.e. missing HAS_CONSTRAINTS relationship

Regards Kiran

Was it helpful?

Solution

  1. MATCH (o:Order) WHERE o:Active AND (o:New OR o:InProcess) RETURN o;
  2. MATCH (o:Order)-[:APPROVED_BY]->(e) WHERE NOT e.InternalId = {InternalId} RETURN o;
  3. MATCH (o:Order) WHERE NOT (o)-[:HAS_CONSTRAINTS]->() RETURN o;

In #2, I assume you are passing in an "InternalId" parameter.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top