neo4j-rstats / neo4r

A Modern and Flexible Neo4J Driver
https://neo4j-rstats.github.io/user-guide/
Other
106 stars 30 forks source link

Cannot query "collect" function #80

Closed cotran2 closed 3 years ago

cotran2 commented 3 years ago

I have no problems using neo4r for most of my queries except for those returning collect(properties) as something, the error is always Error in .x[[i]] : subscript out of bounds. I can use these queries on my neo4j server without any problems. Could someone look into this and help me out? Much appreciated.

davidlrosenblum commented 3 years ago

Hi

Can you flatten the results?

What are you doing with the data you collect()?

Can you share the cypher query?

On Oct 23, 2020, at 12:21 PM, Co Tran notifications@github.com wrote:

I have no problems using neo4r for most of my queries except for those returning collect(properties) as something, the error is always Error in .x[[i]] : subscript out of bounds. I can use these queries on my neo4j server without any problems. Could someone look into this and help me out? Much appreciated.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/neo4j-rstats/neo4r/issues/80, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFBXAGFPWTESZ4HUUJFS5B3SMGURRANCNFSM4S4YOFSA.

cotran2 commented 3 years ago

Here is the query

MATCH (r:Role)-[:ROLE_HAS_ENT_2020]->(e:Entitlement)
                WITH COLLECT(r.role) AS associated_roles
                MATCH (r:Role)-[:ROLE_HAS_ENT_%s]->(e:Entitlement)
                WHERE r.role IN associated_roles
                RETURN r.role AS rid_associated, COUNT(e.entitlement) AS n_ent, COLLECT(e.entitlement) AS eids_associated

I can run this on my neo4j server but not by using neo4r. If I remove the last part, COLLECT(e.entitlement) AS eids_associated, it runs fine with neo4r.

davidlrosenblum commented 3 years ago

The tibble doesn’t seem to be able to handle arrays in a single element, but I’m not an expert there. Cypher I know :-)

This will flatten the response given you one eid_associated per row.

MATCH (r:Role)-[:ROLE_HAS_ENT_2020]->(e:Entitlement) MATCH (r:Role)-[:ROLE_HAS_ENT_S]->(e:Entitlement) WITH r.role AS rid_associated, COUNT(e.entitlement) AS n_ent, COLLECT(e.entitlement) AS eids_associated UNWIND eids_associated as eid_associated return rid_associated,n_ent, eid_associated

HTH

On Oct 23, 2020, at 1:22 PM, Co Tran notifications@github.com wrote:

Here is the query

MATCH (r:Role)-[:ROLE_HAS_ENT_2020]->(e:Entitlement) WITH COLLECT(r.role) AS associated_roles MATCH (r:Role)-[:ROLE_HASENT%s]->(e:Entitlement) WHERE r.role IN associated_roles RETURN r.role AS rid_associated, COUNT(e.entitlement) AS n_ent, COLLECT(e.entitlement) AS eids_associated I can run this on my neo4j server but not by using neo4r. If I remove the last part, COLLECT(e.entitlement) AS eids_associated, it runs fine with neo4r.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/neo4j-rstats/neo4r/issues/80#issuecomment-715471849, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFBXAGFZJBG5ITBMI73FAFDSMG3WFANCNFSM4S4YOFSA.

cotran2 commented 3 years ago

Thanks a lot! This works for me!