Skip to content

Instantly share code, notes, and snippets.

@rvanbruggen
Last active December 17, 2015 17:08
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 rvanbruggen/5643349 to your computer and use it in GitHub Desktop.
Save rvanbruggen/5643349 to your computer and use it in GitHub Desktop.
Beergraph with in-graph index
***
*** SHOW ME THE IN-GRAPH-ALCOHOLINDEX
***
start
alcperc=node:node_auto_index(type="AlcoholPercentage")
match
p=(alcperc-[:PRECEDES]->())
return p;
start
minalcperc=node:node_auto_index(name="0"),
maxalcperc=node:node_auto_index(name="26.5")
match
p = (minalcperc-[:PRECEDES*]-maxalcperc)
return p;
***
*** FINDING other beers that have a "same or similar" AlcoholPercentage as Orval
***
start
orval=node:node_auto_index(name="Orval")
match
orval-[:IS_A]-beertype,
orval-[:HAS_ALCOHOL_PERCENTAGE]-alcperc,
alcperc-[:PRECEDES*0..10]-otheralcperc,
otherbeer-[:HAS_ALCOHOL_PERCENTAGE]-otheralcperc,
otherbeer-[:IS_A]-beertype,
otherbeer-[:BREWS]-otherbrewery
return
otherbeer.name, beertype.name, otherbrewery.name;
***
*** FINDING other beers that have a "similar but not the same" AlcoholPercentage as Orval
***
start
orval=node:node_auto_index(name="Orval")
match
orval-[:IS_A]-beertype,
orval-[:HAS_ALCOHOL_PERCENTAGE]-alcperc,
alcperc-[:PRECEDES*1..10]-otheralcperc,
otherbeer-[:HAS_ALCOHOL_PERCENTAGE]-otheralcperc,
otherbeer-[:IS_A]-beertype,
otherbeer-[:BREWS]-otherbrewery
return
otherbeer.name, beertype.name, otherbrewery.name;
***
*** Finding the other beers from the same brewery that have a similar AlcoholPercentage as duvel
***
start
duvel=node:node_auto_index(name="Duvel")
match
duvel-[:BREWS]-brewery,
duvel-[:IS_A]-beertype,
duvel-[:HAS_ALCOHOL_PERCENTAGE]-alcperc,
alcperc-[:PRECEDES*1..10]-otheralcperc,
otherbeer-[:HAS_ALCOHOL_PERCENTAGE]-otheralcperc,
otherbeer-[:IS_A]-otherbeertype,
otherbeer-[:BREWS]-brewery
return
otherbeer.name, otherbeertype.name, brewery.name, otheralcperc.name
order by
otherbeer.name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment