Database Reference
In-Depth Information
# a specific tag that matches products and users
def getProductsHasSpecificTagAndUserUsesSpecificTag(self, graph_db, wp):
query = neo4j.CypherQuery(graph_db,
" MATCH (t:Tag { wordPhrase: {wp} }) " +
" WITH t " +
" MATCH (p:Product)-[:HAS]->(t)<-[:USES]-(u:User) " +
" RETURN p.title as title,collect(u) as u, collect(distinct t) as t ")
params= {"wp": wp}
result = query.execute(**params)
return result
Location Graph Model
This section explores the location graph model and a few of the operations that typically accompany it. In particular, it
looks at the following:
The spatial plugin
Filtering on location
Products based on location
The example demonstrates how to add a console to enable you to connect products to locations in an ad hoc
manner (Listing 9-38).
Listing 9-38. Location Route for Showing Locations or Locations with Specific Products
# show locations nearby or locations that have a specific product
@route('/location')
def location():
# get user location
userlocations = UserLocation().get_user_location(graph_db,
request.get_cookie(graphstoryUserAuthKey))
distance = request.query.get('distance')
# was distances provided
if distance:
# use first location
ul = userlocations[0]
productNodeId = request.query.get('productNodeId')
# test for productNodeId
if productNodeId:
pnid = int(productNodeId)
# get locations that have product
locations = Location().locations_within_distance_with_product(graph_db,
UserLocation().get_lq(ul, distance), pnid, ul)
productNode = graph_db.node(pnid)
return template('public/templates/graphs/location/index.html',
 
Search WWH ::




Custom Search