Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nawroth/5963970 to your computer and use it in GitHub Desktop.
Save nawroth/5963970 to your computer and use it in GitHub Desktop.
= 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