Hello,
I am trying to "pluck" i.e. retrieve from each item of an array parameter.
Given a users
and posts
parameters:
{
"users" : [ {
"name" : "Andy",
"position" : "Developer"
}, {
"name" : "Michael",
"position" : "Developer"
} ],
"posts" : [ {
"tag" : "lifestyle"
}, {
"tag" : "science"
} ]
}
To try something of the sort:
MATCH (u:User),
(p:Post)
WHERE u.name IN pluck($users.name),
p.tag IN pluck($posts.tag)
RETURN u, p;
I know that this is possible for a parameter of type list, as shown here.
An option would be to UNWIND
as shown here.
But in this particular case this is not convenient since it would result in nested UNWINDs.
To avoid nesting, if we consider FOREACH
another challenge would surface related to variable context.
All in all, as you can see it is not straight forward at all to achieve this relatively simple operation using neither UNWIND
nor FOREACH
.
Please note that the above CYPHER query has been stripped down to the scope of this question.
Is there a way to do this out of the box? Or available in APOC?
Thank you.
Environment:
- Neo4j v4.2.3
- Golang driver