Database Reference
In-Depth Information
Locations with Product
To search for products nearby (Figure 10-17 ), the application makes use of an autosuggest AJAX request, which
ultimately calls the search method in the Product service class. The method, shown in Listing 10-43, returns an array
of objects to the product field in the search form and applies the selected product's productNodeId to the subsequent
location search.
Figure 10-17. Searching for Products in stock at Locations within a certain distance of the User location.
Listing 10-43. The product_search Route and product_search Methods
# return product array as json
get '/productsearch/:q' do
json product_search(neo,params[:q].to_s)
end
# product_search method - located in the Product service class.
def product_search(neo,q)
q= q + ".*"
cypher = " MATCH (p:Product) WHERE lower(p.title) =~ {q}"+
" RETURN count(*) as name, TOSTRING(ID(p)) as id, p.title as label " +
" ORDER BY p.title " +
" LIMIT 5 "
 
Search WWH ::




Custom Search