Database Reference
In-Depth Information
Figure 11-20. Products Purchased by Friends and Matches User's Tags
Using friendsPurchaseTagSimilarity in PurchaseImpl , the method friendsPurchaseTagSimilarity is called,
which is located in the MappedProductUserPurchaseRepository and shown in Listing 11-60.
Listing 11-60. The friendsPurchaseTagSimilarity Method
@Query("MATCH (u:User { userId : {userId} } )-[:FOLLOWS]-(f)-[:MADE]->()-[:CONTAINS]->p " +
" WITH u,p,f " +
" MATCH u-[:USES]->(t)<-[:HAS]-p " +
" RETURN p.productId as productId, " +
" p.title as title, " +
" collect(f.firstname + ' ' + f.lastname) as fullname, " +
" t.wordPhrase as wordPhrase, " +
" count(f) as cfriends " +
" ORDER BY cfriends desc, p.title ")
List<MappedProductUserPurchase> friendsPurchaseTagSimilarity (@Param("userId") String userId);
Products Purchased by Friends Nearby and Matches User's Tags
Finding products that match with a specific user's tags and have been purchased by friends who live within a set
distance of the user is performed by friendsPurchaseTagSimilarityAndProximityToLocation method, easily the
world's longest method name and is located in PurchaseImpl .
The query starts with a location search within a certain distance, then matches the current user's tags to products.
Next, the query matches friends based the location search. The resulting friends are matched against products that are
in the set of user tag matches. The result of the query is shown in Figure 11-21 .
 
Search WWH ::




Custom Search