Neo4/Cypher - Matchs Statistics

(Luineumann) #1

I need to quantify how many nodes and edges are traversed while running a MATCH.

For example, I am using:

MATCH cam = shortestPath ((from: Person) - [r1: personTOfilme |: movieTO Person *] -> (to: Person))
WHERE (from.pes_name = 'Fernanda Torres')
AND (to.pes_name = 'Charles Chaplin')
WITH COLLECT (NODES (cam)) AS ns, SUM (SIZE (RELATIONSHIPS (cam))) AS relCount
UNWIND ns AS nodeList
UNWIND nodeList AS node
RETURN COUNT (DISTINCT node) AS nodeCount, relCount;
````Preformatted text`

However this form does not work if I have two MATCHS or the SIZE

MATCH (p: Person) - [r1: indicated person] -> (pra1: Indicated)
WITH p, COUNT (*) AS qtd_indicacao
WHERE qtd_indicacao = 1
MATCH (p) - [r2: personindicated] -> (pra2: Indicated {pra_winner: 1)
RETURN p.pes_name AS person, f.fil_name, pra2.tpr_name AS the award, pra2.pra_ano AS anoPremio
ORDER BY person

or




> MATCH (p: Movie)
> WITH DISTINCT p,
> SIZE ((p) - [: filmeTOremio] -> ()) +
> SIZE ((p) - [: movieindicated] -> ()) AS qtd_indic,
> SIZE ((p) - [: movieIndicated] -> ({pra_winner: 1})) AS qtd_prem
> WHERE qtd_indic = qtd_prem
> RETURN p.fil_name AS name, qtd_indic, qtd_prem
> ORDER BY qtd_prem DESC;
````Preformatted text`

How can I do this?

0 Likes