Hi michael. I realized I had the same issue a couple of months ago.. will use the same solution..
the weird thing however is that when doing it in the browser, the IN clause allows to compare with nested objects. http://stackoverflow.com/questions/25709309/syntax-issue-passing-objects-as-parameters-in-neo4j-cypher-statement . This is the profile output neo4j-sh (?)$ export reltypes=[[["Person"],"KNOWS","OUT"],[["Person"],"KNOWS","IN"],[["Prologram","User"],"KNOWS","IN"]]; neo4j-sh (?)$ profile MATCH n-[r]-m WHERE id(n) = 0 WITH CASE WHEN startnode(r)=n THEN (CASE WHEN endnode(r)=n THEN 'SELF' ELSE 'OUT' END) ELSE 'IN' END as direction,type(r) as typer,m,r WITH [labels(m),typer,direction] AS reltype WHERE reltype IN {reltypes} RETURN reltype,count(*); ==> +--------------------+ ==> | reltype | count(*) | ==> +--------------------+ ==> +--------------------+ ==> 0 row ==> ==> ColumnFilter(0) ==> | ==> +EagerAggregation ==> | ==> +Filter ==> | ==> +ColumnFilter(1) ==> | ==> +Extract(0) ==> | ==> +ColumnFilter(2) ==> | ==> +Extract(1) ==> | ==> +TraversalMatcher ==> ==> +------------------+------+--------+-------------+-------------------------------------------------------------+ ==> | Operator | Rows | DbHits | Identifiers | Other | ==> +------------------+------+--------+-------------+-------------------------------------------------------------+ ==> | ColumnFilter(0) | 0 | 0 | | keep columns reltype, count(*) | ==> | EagerAggregation | 0 | 0 | | reltype | ==> | Filter | 0 | 0 | | any(-_-INNER-_- in {reltypes} where reltype == -_-INNER-_-) | ==> | ColumnFilter(1) | 11 | 0 | | keep columns reltype | ==> | Extract(0) | 11 | 26 | | reltype | ==> | ColumnFilter(2) | 11 | 0 | | keep columns direction, typer, m, r | ==> | Extract(1) | 11 | 0 | | direction, typer | ==> | TraversalMatcher | 11 | 13 | | m, r, m | ==> +------------------+------+--------+-------------+-------------------------------------------------------------+ ==> Not sure how the "maps" thing would work though.. Met vriendelijke groet / With kind regards Ir. T. Zeppenfeldt van der Waalsstraat 30 6706 JR Wageningen The Netherlands Mobile: +31 6 23 28 78 06 Phone: +31 3 17 84 22 17 E-mail: [email protected] <[email protected]>Web: www.ophileon.com Twitter: tomzeppenfeldt Skype: tomzeppenfeldt 2014-12-02 12:17 GMT+01:00 Michael Hunger <[email protected]> : > can you just try to return {reltypes} > > I think due to json parsing the nested collections in reltypes are turned > into lists which are not equal to the type that is created by the literal > syntax > > could you try a list of maps instead ? > > > > On Tue, Dec 2, 2014 at 11:18 AM, Tom Zeppenfeldt <[email protected] > > wrote: > >> I have an problem , probably related to passing a nested collection as a >> parameter to a cypher query.. >> >> >> In the browser, this works fine: >> >> MATCH n-[r]-m >> WHERE id(n) = 0 >> WITH CASE WHEN startnode(r)=n THEN (CASE WHEN endnode(r)=n THEN 'SELF' >> ELSE 'OUT' END) ELSE 'IN' END as direction,type(r) as typer,m,r >> WITH [labels(m),typer,direction] AS reltype >> WHERE reltype IN >> *[[['Person'],'KNOWS','OUT'],[['Person'],'KNOWS','IN'],[['Prologram','User'],'KNOWS','IN']]* >> RETURN reltype,count(*) >> >> doing this using REST works fine too and also returns the expected result >> >> *query* >> >> { >> "query" : "MATCH n-[r]-m WHERE id(n) = 0 WITH CASE WHEN startnode(r)=n >> THEN (CASE WHEN endnode(r)=n THEN 'SELF' ELSE 'OUT' END) ELSE 'IN' END as >> direction,type(r) as typer,m,r WITH [labels(m),typer,direction] AS reltype >> WHERE reltype IN >> [[['Person'],'KNOWS','OUT'],[['Person'],'KNOWS','IN'],[['Prologram','User'],'KNOWS','IN']] >> RETURN reltype,count(*)" >> } >> } >> >> *result : * >> >> >> { >> "columns": [ >> "reltype", >> "count(*)" >> ], >> "data": [ >> [ >> [ >> [ >> "Person" >> ], >> "KNOWS", >> "OUT" >> ], >> 2 >> ], >> [ >> [ >> [ >> "Prologram", >> "User" >> ], >> "KNOWS", >> "IN" >> ], >> 1 >> ], >> [ >> [ >> [ >> "Person" >> ], >> "KNOWS", >> "IN" >> ], >> 1 >> ] >> ] >> } >> >> however: passing the collection as a parameter does not work: >> >> { >> "query" : "MATCH n-[r]-m WHERE id(n) = 0 WITH CASE WHEN startnode(r)=n >> THEN (CASE WHEN endnode(r)=n THEN 'SELF' ELSE 'OUT' END) ELSE 'IN' END as >> direction,type(r) as typer,m,r WITH [labels(m),typer,direction] AS reltype >> WHERE reltype IN {reltypes} RETURN reltype,count(*)", >> "params": { >> "reltypes": >> [[["Person"],"KNOWS","OUT"],[["Person"],"KNOWS","IN"],[["Prologram","User"],"KNOWS","IN"]] >> } >> } >> >> returns an empty result >> >> { >> "columns": [ >> "reltype", >> "count(*)" >> ], >> "data": [] >> } >> >> -- >> 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 [email protected]. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > 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 [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
