Database Reference
In-Depth Information
Both
getProductsHasATagAndUserUsesAMatchingTag
and
getProductsHasTagAndUserUsesTag
methods
in the
MappedProductUserTagRepository
interface return a List of MappedProductUserTag objects. The
getProductsHasATagAndUserUsesAMatchingTag
does not require any arguments and will simply return the product
title as well as the user and tags that are a match. However, the
getProductsHasTagAndUserUsesTag
, which is shown
in Listing 11-49, requires a word/phrase as well as a username. In addition, this will result in a list of
MappedProducts
as opposed to
MappedProductUserTag
.
Listing 11-49.
The Products Matching User Tags Methods and the
MappedProductUserTag
Interface in the
MappedProductUserTagRepository
Interface
// getProductsHasATagAndUserUsesAMatchingTag
@Query("MATCH (p:Product)-[:HAS]->(t)<-[:USES]-(u:User) " +
" RETURN p.title as title, collect(u.username) as u, collect(distinct t.wordPhrase) as t ")
List<MappedProductUserTag>
getProductsHasATagAndUserUsesAMatchingTag
();
// getProductsHasTagAndUserUsesTag
@Query("MATCH (t:Tag { wordPhrase: {wp} }),(u:User { username: {username} }) " +
" WITH t,u " +
" MATCH (p:Product)-[:HAS]->(t)<-[:USES]-(u) " +
" RETURN ID(p) as nodeId, p.title, p.description, p.tagstr ")
List<MappedProduct>
getProductsHasTagAndUserUsesTag
(@Param("wp") String wp, @Param("username")
String username);
// MappedProductUserTag
@QueryResult
@NodeEntity
public interface MappedProductUserTag {
@ResultColumn("title")
String getTitle();
@ResultColumn("u")
List<String> getUsers();
@ResultColumn("t")
List<String> getTags();
}
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.