I have a node containing these property names:
(That is, using the query
match (x) where x.name="a" return keys(x) will return the result
["name", "A", "B", "C", ..., "ZA", "ZB", "ZC", ...]).
I want to return all properties whose names start with
match (x) where x.name="a" return x.ZA, x.ZB, x.ZC, ...
But since each node has a different number of
Z* properties, I need a way to not specify the properties when returning.
Is there a way to do so? I read the manual for
RETURN and Filtering Query Results but there is nothing useful.
(This question is also asked on Stack Overflow)
Hi @Ooker ,
You can check the apoc.any.properties function which returns a map with a given list of node attributes (it cannot use regex, but if you know the properties of your nodes, you can search the required attributes by name). Please find below an example:
UNWIND apoc.any.properties(s,["Z", "Z2"]) AS properties
Hope this helps
WHERE x.name = "a"
RETURN apoc.map.removeKeys(x, [p IN keys(x) WHERE NOT p STARTS WITH "Z"])