Database Reference
In-Depth Information
Locations with Product
To search for products nearby, as shown in Figure 7-13 , the application makes use of an autosuggest AJAX request,
which ultimately calls the search method in the ProductService class. The method, shown in Listing 7-48, returns
an array of MappedProductSearch objects to the product field in the search form and applies the selected product's
productNodeId to the subsequent location search (Listing 7-49).
Figure 7-13. Searching for Products in stock at Locations within a certain distance of the User location
For almost all cases, it is recommended not to use the graphId because it can be recycled when its node is
deleted. In this case, the productNodeId should be consider safe to use, because products would not be in danger of
being deleted but only removed from a Location relationship.
Listing 7-48. Search Method in ProductService
public MappedProductSearch[] search(String q)
{
q = q.Trim().ToLower() + ".*";
MappedProductSearch[] mappedProductSearch=_graphClient.Cypher
.Match("(p:Product)")
.Where("lower(p.title) =~ {q}")
 
Search WWH ::




Custom Search