Forked from rvanbruggen/Business Rule Recommendation gist
Last active
December 19, 2015 13:40
-
-
Save nawroth/5963970 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= Business Rule / Recommendation gist = | |
Let's see if I can create a graphgist for business rules/simple recommendations. | |
//console | |
First, lets create the graph: | |
//setup | |
[source,cypher] | |
---- | |
CREATE (rik:person{name:'Rik'}), (london:city{name:'London'}), (age:age{name:'39'}), (kid:child{name:'Toon'}) | |
CREATE (xbox:console{name:'Xbox 360'}) | |
CREATE london<-[:LIVES_IN]-rik-[:HAS_AGE]->age | |
CREATE rik-[:HAS_KID]->kid | |
CREATE rik-[:SHOULD_RECEIVE_PROMO_FOR]->xbox | |
---- | |
//graph | |
Hover over the nodes to see the +name+ node property in the Graph above. | |
It then becomes quite easy to see that this is almost like the equivalent - but a much richer, versatile equivalent of having a traditional "business rule" that would say: | |
[source] | |
---- | |
IF | |
rik lives in london, | |
AND is of age 39 | |
AND has a kid | |
THEN | |
propose Xbox 360 promo | |
ELSE | |
proceed with something else ;-) ... | |
---- | |
In graph terms, we would express this as a Cypher query: | |
[source,cypher] | |
---- | |
MATCH | |
rik:person-[:HAS_AGE]->age:age, | |
rik:person-[:LIVES_IN]->london:city, | |
rik:person-[:HAS_KID]->kid:child, | |
rik:person-[:SHOULD_RECEIVE_PROMO_FOR]->sometoy | |
WHERE | |
rik.name='Rik' | |
RETURN | |
rik.name, sometoy.name; | |
---- | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment