Database Reference
In-Depth Information
# products that share a specific tag with a user
def get_products_has_specific_tag_and_user_users_specific_tag(neo, wp)
cypher = " 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 "
results=neo.execute_query(cypher, {:wp => wp} )
results["data"].map {|row| Hash[results["columns"].zip(row)] }
end
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 10-41).
Listing 10-41. Location Route for Showing Locations or Locations with Specific Product
# show locations nearby or locations that have a specific product
get '/location' do
@title="Location"
#get their primary location
@mappedUserLocation=get_user_location(neo,request.cookies[graphstoryUserAuthKey])
# was a distance param provided?
if(params[:distance])
#make the location query
lq = get_lq(@mappedUserLocation[0],params[:distance].to_s)
# was a product node id provided?
if(params[:productNodeId].empty?)
# if no, just get locations of type 'business'
@locations=locations_within_distance(neo, lq, @mappedUserLocation[0],"business")
else
#otherwise find locations that have this product
pnid=params[:productNodeId].to_i
@productnode=neo.get_node(pnid)["data"]
@locations=locations_within_distance_with_product(neo,lq,pnid, @mappedUserLocation[0])
end
end
mustache :"graphs/location/index"
end
 
Search WWH ::




Custom Search