Database Reference
In-Depth Information
" MATCH u-[:FOLLOWS]->(f)-[:HAS]->(n) " .
" WITH p,f,t " .
" MATCH f-[:MADE]->()-[:CONTAINS]->(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 ";
$query = new Everyman\Neo4j\Cypher\Query(Neo4Client::client(), $queryString, array(
'u' => $username,
'lq' => $lq
));
$result = $query->getResultSet();
return $result;
}
The query begins 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 8-21 .
Figure 8-21. Products Purchased by Friends Nearby and Matches User's Tags
Summary
This chapter presented the setup for a development environment for PHP and Neo4j and sample code using the
Neo4jPHP driver. It proceeded to look at sample code for setting up a social network and examining interest within
the network. It then looked at the sample code for capturing and viewing consumption—in this case, product
views—and the queries for understanding the relationship between consumption and a user's interest. Finally, it
looked at using geospatial matching for locations and examples for understanding user intent within the context of
their location, social network, and interests.
The next chapter will review using Python and Neo4j, covering the same concepts presented in this chapter but in
the context of a Python driver for Neo4j.
 
Search WWH ::




Custom Search