neo4j - What is the cypher query for one node but not another? -


i have graph looks -

customer-hasorder->order order-haslineitem->orderlineitem orderlineitem-hasservice->service orderlineitem-providedon->providedondate orderlineitem-providedby->vendor 

i need determine if particular service, service named "a" provided customer on date without service, service named "b", being provided on same date same vendor. should true no matter how many orders submitted customer on given day. in other words, service "a" should provided on same day service "b" same vendor time customer orders "a."

here have find customers had "a" not "b" on same day -

start       s1 = node:service(id="a"),     s2 = node:service(id = "b"), match     customer-[:hasorder]->(o1)-[:haslineitem]->li1-[:hasservice]->s1,     customer-[:hasorder]->(o2)-[:haslineitem]->li2-[r?:hasservice]->s2,     ol1-[:providedby]->p1,     ol2-[:providedby]->p2,     ol1-[:providedon]->d1,     ol2-[:providedon]->d2     d1 = d2 , p1 = p2 , r null     return customer 

i decided come here after nose started bleeding trying figure out cypher query this.

looking @ different angle, aggregating on relevant nodes (customer,provider,date)

start       service = node:service("id:(a b)"), match     customer-[:hasorder]->(order)-[:haslineitem]->item-[:hasservice]->service,     item-[:providedby]->provider,     item-[:providedon]->date     customer,provider,date,count(distinct service) service_count     service_count = 1 return customer,provider,date 

you path expressions check if line-item exists same provider , date not service b.

start       s1 = node:service(id="a"),     s2 = node:service(id="b"), match     customer-[:hasorder]->(o1)-[:haslineitem]->li1-[:hasservice]->s1,     customer-[:hasorder]->(o2)-[:haslineitem]->li2     li1-[:providedby]->provider,     li2-[:providedby]->provider,     li1-[:providedon]->date,     li2-[:providedon]->date     not (li2-[:hasservice]->s2)  return customer 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -