= A case of nested subcategories

//console

In many multilingual systems, there are nested 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 http://wordnetweb.princeton.edu/perl/webwn?o2=&o0=1&o8=1&o1=1&o7=&o5=&o9=&o6=&o3=&o4=&s=drink[Wordnet Project].

== The setup


//setup
[source,cypher]
----
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)
----

//graph

//table


== Find English things that are beverages 

Now, let's find the German captions of products that are attached to the category or one of its subcategories of the one that has an English caption `beverages`.

[source,cypher]
----
MATCH 
  (bev_caption)<-[:CAPTION]-bev<-[:IS_A*0..]-(sub_cat)-[:CAPTION]->(caption),
  bev-[:CAPTION]->(cap2),(caption)<-[:TAGGED]-(product) 
WHERE 
  bev_caption.caption = 'beverages' AND 
  caption.lang='DE' AND cap2.lang='DE' 
RETURN bev_caption.caption AS search_term,cap2.caption AS search_term_DE,caption.caption AS found_cat, product.name
----

//table
