Thanks Michael, worked!!!! That was very helpful.
On Wednesday, March 30, 2016 at 9:49:04 PM UTC+2, Michael Hunger wrote: > > Do you have a test-dataset somewhere? > > 0. what neo4j version do you use? > 1. I would probably use only one indexed date property for > StoreCustomerTransaction (you have a typo in the label) > 2. you don't need empty matches > 3. don't include (s) in your intermediate WIHT if you don't use it later > 4. switch the START clause to a MATCH (c) WHERE id(c) = 84531 > 5. your arrow in the WHERE from customer was wrong > (:TransactionLineItems)-[:BasketContained]->(c) > > MATCH (c)-[:BasketContained]-> > (:TransactionLineItems) > -[:IsOneOf]-> > (s:StoreItem) > <-[:IsOneOf]- > (tl:TransactionLineItems) > <-[:BasketContained]- > (m:StoreCutomerTransaction) > WHERE m.date = "2015-10-29" and id(c) = 84531 > WITH distinct m, c > Match > (m)-[:BasketContained]->(:TransactionLineItems)-[:IsOneOf]->(RecomendedItems:StoreItem) > WHERE NOT > exists((RecomendedItems)-[:IsOneOf]->(:TransactionLineItems)<-[:BasketContained]-(c)) > RETURN RecomendedItems.ItemName, COUNT(*) AS CountRecomendedItems > Order by CountRecomendedItems desc > LIMIT 10; > > > there is also a trick you can do, to speed up the NOT EXISTS check > > MATCH > (c)-[:BasketContained]->(:TransactionLineItems)-[:IsOneOf]->(s:StoreItem) > WHERE id(c) = 84531 > WITH c, collect(s) as storeItems, reduce(a = "-", id in collect(id(s)) | a > + id + "-") as ids > UNWIND storeItems as s > MATCH (s)<-[:IsOneOf]- > (tl:TransactionLineItems) > <-[:BasketContained]- > (m:StoreCutomerTransaction) > WHERE m.date = "2015-10-29" > WITH distinct m, c, ids > Match > (m)-[:BasketContained]->(:TransactionLineItems)-[:IsOneOf]->(RecomendedItems:StoreItem) > WHERE NOT ids CONTAINS toString(id(RecomendedItems)) > RETURN RecomendedItems.ItemName, COUNT(*) AS CountRecomendedItems > Order by CountRecomendedItems desc > LIMIT 10; > > > Please try it and let me know. > > > Am 30.03.2016 um 21:14 schrieb Grant <[email protected] <javascript:>>: > > Hi All, > > So here is the senario, > > 1. Customer A places items into his/her basket > 2. Other customers place items into their baskets. > 3. Find the items in the "other" baskets that are not in customer A's > basket > > Everything seems find until the point where i need to filter out customer > A's items. > > > START c = node(84531) > MATCH (c)-[:BasketContained]-> > (:TransactionLineItems) > -[:IsOneOf]-> > (s:StoreItem) > <-[:IsOneOf]- > (tl:TransactionLineItems) > <-[:BasketContained]- > (m:StoreCutomerTransaction) > WHERE > m.Month = 10 > and m.Year = 2015 > and m.Day = 29 > WITH distinct s, m, c > Match (m) > -[:BasketContained]-> > (:TransactionLineItems) > -[:IsOneOf]-> > (RecomendedItems:StoreItem) > WITH RecomendedItems, c > MATCH (RecomendedItems) > MATCH (c) > WHERE NOT > exists((RecomendedItems)-[:IsOneOf]->(:TransactionLineItems)-[:BasketContained]->(c)) > RETURN RecomendedItems.ItemName, COUNT(RecomendedItems.ItemName) AS > CountRecomendedItems > Order by CountRecomendedItems desc > > Any help would be appreciated. > > -- > You received this message because you are subscribed to the Google Groups > "Neo4j" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <javascript:>. > For more options, visit https://groups.google.com/d/optout. > > > -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
