Skip to content

Instantly share code, notes, and snippets.

@peterneubauer
Last active December 23, 2015 08:38
Show Gist options
  • Select an option

  • Save peterneubauer/6608600 to your computer and use it in GitHub Desktop.

Select an option

Save peterneubauer/6608600 to your computer and use it in GitHub Desktop.

Vienna is cool

In many multilingual systems, there are hierarchis of categories, connected to different products that need to be searched by customers with different language preferences. Here is a possible approach, inspired by the Wordnet Project.

The setup

CREATE (getr{name:'C1'})
CREATE (alc{name:'C2'})
CREATE ({caption:'beverages', lang:'EN'})<-[:CAPTION]-(getr)
CREATE (getr)-[:CAPTION]->({caption:'Getraenke', lang:'DE'})
CREATE ({caption:'alcoholic stuff', lang:'EN'})<-[:CAPTION]-(alc)
CREATE (alc)-[:CAPTION]->(alc_de{caption:'Alkoholika', lang:'DE'})
CREATE (getr)<-[:IS_A]-(alc)
CREATE ({name:"Wein"})-[:TAGGED]->(alc_de)

Find English things that are beverages

MATCH (bev_caption)<-[:CAPTION]-bev<-[:IS_A*0..]-(cat)-[:CAPTION]-(caption)
WHERE bev_caption.caption = 'beverages' AND caption.lang='DE'
RETURN bev_caption.caption, caption.caption
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment