*For a faceted search I first do a MATCH on multiple conditions, and then 
count the remaining facet values. *


match 

    
(n:Document)-[:PUBLISHED_ON]->(d:Day)<-[:HAS_DAY]-(m:Month)<-[:HAS_MONTH]-(y:Year
 
{year:2013}),

    (n)<-[:MENTIONED_IN|HAS_CHILD*1..]-(l:Location {name:'Netherlands'} ) 

with n

//location facet

MATCH (n)<-[:MENTIONED_IN|HAS_CHILD*1..]-(l:Location) 
RETURN 'Location' as facet,l.name as facetvalue ,count(n) as facetcount 
order by facetcount

UNION

//month facet

MATCH 
(n)-[:PUBLISHED_ON]->(d:Day)<-[:HAS_DAY]-(m:Month)<-[:HAS_MONTH]-(y:Year) 
RETURN 'Period' as facet,m.month as facetvalue, count(n) as facetcount 
order by facetcount;

+-------------------------------------------+

| facet      | facetvalue      | facetcount |

+-------------------------------------------+

| "Location" | "Noord-Brabant" | 3          |

| "Location" | "Gelderland"    | 4          |

| "Location" | "Groningen"     | 4          |

| "Location" | "Zuid-Holland"  | 4          |

| "Location" | "Overijssel"    | 5          |

| "Location" | "Flevoland"     | 5          |

| "Location" | "Friesland"     | 6          |

| "Location" | "Utrecht"       | 8          |

| "Location" | "Limburg"       | 8          |

| "Location" | "Drenthe"       | 10         |

| "Location" | "Noord-Holland" | 10         |

| "Location" | "Zeeland"       | 12         |

| "Location" | "Netherlands"   | 90         |

| "Period"   | 6               | 142        |

| "Period"   | 12              | 155        |

| "Period"   | 3               | 156        |

| "Period"   | 4               | 162        |

| "Period"   | 11              | 164        |

| "Period"   | 7               | 164        |

| "Period"   | 1               | 167        |

| "Period"   | 2               | 171        |

| "Period"   | 8               | 172        |

| "Period"   | 5               | 175        |

| "Period"   | 10              | 177        |

| "Period"   | 9               | 195        |

+-------------------------------------------+

*when I switch the two elements of the UNION, so first the month facet and 
then the location facet, I get different counts ( I don't meant that the 
results are in another order, b/c that's obvious) , but it seems that the 
WITH is only applied to the first element of UNION*


neo4j-sh (?)$ match 
(n:Document)-[:PUBLISHED_ON]->(d:Day)<-[:HAS_DAY]-(m:Month)<-[:HAS_MONTH]-(y:Year
 
{year:2013}),

>       (n)<-[:MENTIONED_IN|HAS_CHILD*1..]-(l:Location {name:'Netherlands'} 
) 

> with n

> //month facet

> MATCH 
(n)-[:PUBLISHED_ON]->(d:Day)<-[:HAS_DAY]-(m:Month)<-[:HAS_MONTH]-(y:Year) 

> RETURN 'Period' as facet,m.month as facetvalue, count(n) as facetcount 
order by facetcount

> UNION

> //location facet

> MATCH (n)<-[:MENTIONED_IN|HAS_CHILD*1..]-(l:Location) 

> RETURN 'Location' as facet,l.name as facetvalue ,count(n) as facetcount 
order by facetcount;

+-------------------------------------------+

| facet      | facetvalue      | facetcount |

+-------------------------------------------+

| "Period"   | 7               | 4          |

| "Period"   | 12              | 6          |

| "Period"   | 11              | 6          |

| "Period"   | 6               | 7          |

| "Period"   | 8               | 7          |

| "Period"   | 2               | 7          |

| "Period"   | 4               | 7          |

| "Period"   | 3               | 8          |

| "Period"   | 10              | 8          |

| "Period"   | 9               | 9          |

| "Period"   | 5               | 10         |

| "Period"   | 1               | 11         |

| "Location" | "Noord-Brabant" | 135        |

| "Location" | "Limburg"       | 140        |

| "Location" | "Overijssel"    | 142        |

| "Location" | "Friesland"     | 144        |

| "Location" | "Utrecht"       | 147        |

| "Location" | "Groningen"     | 147        |

| "Location" | "Flevoland"     | 154        |

| "Location" | "Noord-Holland" | 160        |

| "Location" | "Drenthe"       | 161        |

| "Location" | "Zuid-Holland"  | 161        |

| "Location" | "Gelderland"    | 165        |

| "Location" | "Zeeland"       | 171        |

| "Location" | "Netherlands"   | 2012       |

+-------------------------------------------+

-- 
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.

Reply via email to