Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NEO4J using an array or collection as a parameter in cypher query

I am trying to do call a cypher query (in java) passing in parameters to do something like:

WHERE node.property IN [{param}]

Full example:

START person=node:persons('Name:*')
MATCH person->[:Girl]->friend
WHERE person.Name IN [{Names}] AND friend.Hair = 'Blond'
RETURN person.Name, friend.Name

For the parameter I have tried using the following:

  1. Collection containing strings
  2. Array containing strings
  3. Delimited string like "'Joe Blow', 'Blow Joe'"

I really thought the last one would work but I think the parameter is being replaced as a single string i.e. ["'Joe Blow', 'Blow Joe'"] and not ['Joe Blow', 'Blow Joe']. I proved this by passing in one value, and that worked. I tried tracing through the code but got lost in scala.

Any other options, thoughts?

Cheers

like image 999
sverze Avatar asked Nov 30 '12 11:11

sverze


1 Answers

It should work better if you remove the square brackets after the IN keyword, and use a collection as the parameter.

START person=node:persons('Name:*')
MATCH person->[:Girl]->friend
WHERE person.Name IN {Names} AND friend.Hair = 'Blond'
RETURN person.Name, friend.Name
like image 179
Werner Kvalem Vesterås Avatar answered Sep 21 '22 22:09

Werner Kvalem Vesterås