Hi all, Recently I worked with Michael Hunger on a typical faceted search case, but since we haven't found the holy grail yet, I'm also sharing our findings over here.
The dropboxlink https://www.dropbox.com/s/65rc2sz6p2lrpge/TomZepFacets.tar.gz contains a Neo4j 2.1.2 db with about 6000 random nodes, modeled as follows (the db also contains a :Meta model). In terms of cardinality each :Datapoint has 1 :HAS_LOCATION and 1 :HAS_PERIOD relationship .[image: Inline afbeelding 1] <https://mail.google.com/mail/u/0/?ui=2&ik=cffa13707e&view=att&th=146c0088c0e62770&attid=0.1&disp=emb&realattid=ii_146beff0f2f2d71d&zw&atsh=1> When requesting a filtered set of datapoints (with filters applied for a country and a period of time) I succeeded in getting the counts for one of the facets, but not for both of them in a single cypher. The current approach is as follows: - retrieve all descendants of the filtervalue in the :Poi and :Period hierarchies, including the filtervalue itself. This results in a set of nodes/leaves - match all :Datapoint nodes with the descendants. neo4j-sh (?)$ cypher 2.1.experimental match (poi)<-[:HAS_CHILD*0..]-(poif)<-[:HAS_CHILD*0..1]-(poiq:Poi {name: "Netherlands"}) > with poi,poif > match (period)<-[:HAS_CHILD*0..]-(periodf)<-[:HAS_CHILD*0..1]-(periodq:Period {name: "2014-Q2"}) > with poif,periodf,poi,period > match (poi)<-[hl:HAS_LOCATION]-(dp)-[hp:HAS_PERIOD]->(period) > with *poif*.name as fname ,count(distinct dp) as fcount > return [fname,fcount] as facets; +-----------------------+ | facets | +-----------------------+ | ["Overijssel",73] | | ["Drenthe",31] | | ["Utrecht",73] | | ["Gelderland",143] | | ["Flevoland",22] | | ["Netherlands",1089] | | ["Groningen",45] | | ["Noord-Holland",128] | | ["Noord-Brabant",185] | | ["Limburg",103] | | ["Zuid-Holland",182] | | ["Zeeland",39] | | ["Friesland",65] | +-----------------------+ 13 rows 434 ms neo4j-sh (?)$ cypher 2.1.experimental match (poi)<-[:HAS_CHILD*0..]-(poif)<-[:HAS_CHILD*0..1]-(poiq:Poi {name: "Netherlands"}) > with poi,poif > match (period)<-[:HAS_CHILD*0..]-(periodf)<-[:HAS_CHILD*0..1]-(periodq:Period {name: "2014-Q2"}) > with poif,periodf,poi,period > match (poi)<-[hl:HAS_LOCATION]-(dp)-[hp:HAS_PERIOD]->(period) > with *periodf*.name as fname ,count(distinct dp) as fcount > return [fname,fcount] as facets; +------------------+ | facets | +------------------+ | ["2014-M05",352] | | ["2014-M04",355] | | ["2014-Q2",1089] | | ["2014-M06",371] | +------------------+ 4 rows 327 ms Please note we had the best results with the Cypher 2.1.experimental that was announced here <http://neo4j.com/blog/neo4j-2-1-graph-etl/> My concrete question: Anyone has got an idea how to construct a cypher that returns counts for both facets (and in fact n facets, since the real case uses 4 hierarchical facets) ? -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.