简体   繁体   中英

AQL and Graph Traversal: Product recommendation example

I have been learning Arangodb and graph traversal using AQL, and I have looked at some of the examples that can be found online like flight paths, actors and movies, but I have trouble wrapping my head around writing what I initially thought would be a simple product recommendation experiment where a customer is recommended products he/she has not bought based on other customers' (who have made similar purchases) purchases.

This is what I managed to achieved to so far, retrieving products that other customers' who have purchased the same product as the current customer

FOR products IN 1..1 OUTBOUND 'customers/118685' bought
    FILTER products._id LIKE "products/%" 
    FOR other_buyers IN 1..1 INBOUND products bought
    FILTER other_buyers._id != 'customers/118685' 
    FOR other_buyers_products IN 1..1 OUTBOUND other_buyers bought
    return other_buyers_products

Also, I haven't reached the stage where the recommendation would could be refined to customers who have made more similar purchases (ie based on higher count) with the current customer. Appreciate advice or helpful examples.

this is a very open question. a more precise question would result in more and better answers... but i will give it a try.

you can express your current query in a more condense way:

FOR product IN 3..3 ANY 'customers/1' purchases
RETURN DISTINCT product

counting occurrences of a product can be added easely with COLLECT :

FOR product IN 3..3 ANY 'customers/1' purchases
COLLECT pid = product._id WITH COUNT INTO count
RETURN { pid, count }

this is still a very naive approach. you will end up with recommendations like "you once bought banana, you should by toilet paper", because everybody bought those things eventually. you can improve your results by not just saving what product a customer bought, but also when. Then you will be able to find out what products are bought together often, fe a flashlight and batteries.

look around on the inte.net for further inspiration, fe here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM