QnaList > Groups > Neo4j > Mar 2016
faq

[Neo4j] Neo4j Recommendation Query

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)
(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].
For more options, visit https://groups.google.com/d/optout.

asked Mar 30 2016 at 12:14

Grant 's gravatar image



2 Replies for : [Neo4j] Neo4j Recommendation Query
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)
		(RecomendedItems:StoreItem)
WHERE NOT exists((RecomendedItems)-[:IsOneOf]->(:TransactionLineItems)(: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)(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.
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.

answered Mar 30 2016 at 12:48

Michael Hunger 's gravatar image


Thanks Michael, worked!!!! That was very helpful.
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.

answered Apr 1 2016 at 01:29

Grant 's gravatar image


Related discussions

Tagged

Group Neo4j

asked Mar 30 2016 at 12:14

active Apr 1 2016 at 01:29

posts:3

users:2

Neo4j

©2013 QnaList.com