cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Apoc.agg.statistics() is not working?

gigauser
Graph Buddy

neo4j : several recent versions, apoc: several recent versions

I tried it in https://guides.neo4j.com/4.0-intro-graph-algos-exercises/LabelPropagation.html
UNWIND ['distance','inverse_distance'] as property
MATCH (:Place)-[r:EROAD]->(:Place)
RETURN property, apoc.agg.statistics(r[property]) as stats

It returns this error:
Neo.ClientError.Procedure.ProcedureCallFailed
Failed to invoke function apoc.agg.statistics: Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1

1 ACCEPTED SOLUTION

It seems like the solution to the exercise left out the percentiles parameter from the apoc.agg.statistics() function. The correct syntax should be

UNWIND ['distance','inverse_distance'] as property
MATCH (:Place)-[r:EROAD]->(:Place)
RETURN property, apoc.agg.statistics(r[property], [0.5,0.75,0.9,0.95,0.99]) as stats

Hope this helps!

-Jorge

View solution in original post

2 REPLIES 2

It seems like the solution to the exercise left out the percentiles parameter from the apoc.agg.statistics() function. The correct syntax should be

UNWIND ['distance','inverse_distance'] as property
MATCH (:Place)-[r:EROAD]->(:Place)
RETURN property, apoc.agg.statistics(r[property], [0.5,0.75,0.9,0.95,0.99]) as stats

Hope this helps!

-Jorge

Yes, it works now!!
Thank your for the help.

Hope God bless you.