Database Reference
In-Depth Information
" collect(f.firstname + ' ' + f.lastname) as fullname, " .
" t.wordPhrase as wordPhrase, " .
" count(f) as cfriends " .
" ORDER BY cfriends desc, p.title ";
$query = new Everyman\Neo4j\Cypher\Query(Neo4Client::client(), $queryString, array(
'u' => $username
));
$result = $query->getResultSet();
return $result;
}
Products Purchased by Friends Nearby and Matches User's Tags
To find 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 the friendsPurchaseTagSimilarityAndProximityToLocation method, easily the
world's longest method name, and is located in the Purchase class (Listing 8-49).
Listing 8-49. The friendsPurchaseTagSimilarityAndProximityToLocation Route
// friends that are nearby bought this product. the product should also matches tags of the current
user
$app->get('/intent/friendsPurchaseTagSimilarityAndProximityToLocation',
$isLoggedIn, function() use ($app){
// get the user's locations
$userlocations = UserLocation::getUserLocation($_SESSION['username']);
// create the location query using first location
$lq = UserLocation::getLQ($userlocations[0],"10.00");
# get result set
$mappedProductUserPurchaseList =
Purchase::friendsPurchaseTagSimilarityAndProximityToLocation($_SESSION['username'],$lq);
$app->view()->setData(array(
'mappedProductUserPurchaseList' => $mappedProductUserPurchaseList,
'mappedUserLocation'=>$userlocations,
'title' =>"Products Purchased by Friends Nearby and Matches User's Tags"));
$app->render('graphs/intent/index.mustache');
})->name('friendsPurchaseTagSimilarityAndProximityToLocation');
The friendsPurchaseTagSimilarityAndProximityToLocation route calls the
friendsPurchaseTagSimilarityAndProximityToLocation method shown in Listing 8-50.
Listing 8-50. The friendsPurchaseTagSimilarityAndProximityToLocation Method in the Purchase Class
// user's friends' purchases who are nearby and the products match the user's tags
public static function friendsPurchaseTagSimilarityAndProximityToLocation($username,$lq){
$queryString = " START n = node:geom({lq}) " .
" WITH n " .
" MATCH (u:User {username: {u} } )-[:USES]->(t)<-[:HAS]-p " .
" WITH n,u,p,t " .
 
Search WWH ::




Custom Search