Database Reference
In-Depth Information
Interest Graph Model
This section looks at the interest graph and examines some basic ways it can used to explicitly define a degree of
interest. The following topics are covered:
Adding filters for owned content
Adding filters for connected content
Analyzing connected content (count tags)
Tag Entity
Listing 7-36 displays the Tag entity, which will be used determine a user's interest and network of interest based
on user she follows. The tag entity also has incoming relationships with Users and Products, but the relationship
is defined using the other entities. To that point, it is not necessary to explicitly annotate the relationships on both
entities because one implies the other.
Listing 7-36. The Tag Object
public class Tag
{
public long nodeId { get; set; }
public NodeReference noderef { get; set; }
public string wordPhrase { get; set; }
}
Interest in Aggregate
Inside the view method of the InterestController , we retrieve all of the user's tags and their friends' tags by calling,
respectively, the userTags and tagsInNetwork methods found in the TagService class (Listing 7-37).
Listing 7-37. tagsInMyNetwork Located in the TagService Class
public GraphStory tagsInMyNetwork(GraphStory graphStory)
{
graphStory.tagsInNetwork = _graphClient.Cypher
.Start(new { u = graphStory.user.noderef })
.Match("u-[:FOLLOWS]->f")
.With("distinct f")
.Match(" f-[:CURRENTPOST]-lp-[:NEXTPOST*0..]-c")
.With("distinct c")
.Match(" c-[ct:HAS]->(t)")
.With("distinct ct, t")
.Return(() => Return.As<MappedContentTag>("{name: t.wordPhrase,
label: t.wordPhrase, " +
" id: count(*) }"))
.OrderByDescending("count(*) ")
.Results.ToList();
 
Search WWH ::




Custom Search